{"size": 2218, "ext": "js", "max_stars_repo_path": "src/api.js", "max_stars_repo_name": "vuzuk/webapp", "max_stars_repo_stars_event_min_datetime": "2020-07-23T07:00:56.000Z", "max_stars_repo_stars_event_max_datetime": "2020-07-23T07:00:56.000Z", "max_issues_repo_path": "src/api.js", "max_issues_repo_name": "vuzuk/webapp", "max_issues_repo_issues_event_min_datetime": "2018-04-11T11:01:14.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-11T17:47:39.000Z", "max_forks_repo_path": "src/api.js", "max_forks_repo_name": "vuzuk/webapp", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 30.3835616438, "max_line_length": 96, "alphanum_fraction": 0.6009918846}
import axios from 'axios';

const DOMAIN = process.env.DOMAIN;

export function fetchPost(bloggerName, slug) {
  return axios.get(`http://${DOMAIN}/api/unsecure/getBlog/${bloggerName}/${slug}`);
}

export function getBlogsByCategory(id, offset, limit) {
  return axios.get(`http://${DOMAIN}/api/unsecure/getBlogsByCategory/${id}/${offset}/${limit}`);
}

export function getBlogger(username) {
  return axios.get(`http://${DOMAIN}/api/unsecure/getBlogger/${username}`)
}

export function getPostsByTag(tag) {
  return axios.get(`http://${DOMAIN}/api/unsecure/getBlogsByTag/${tag}`)
}

export function getPostsByQuery(query) {
  query = query.replace(/-/g,'%')
  return axios.get(`http://${DOMAIN}/api/unsecure/searchBlogs/0/10?title=${query}`)
}

export function getSearch() {
  return axios.all([
    axios.get(`http://${DOMAIN}/api/unsecure/getTrendingBlogs/0/6`), //get trending tags
    // axios.get(`http://${DOMAIN}/api/unsecure/getLatestBlogs/0/5`)
  ])
   .then(axios.spread((blogs) => {
     return new Promise((res, rej) => {
       res({
         data: {
           msg: {
            blogs: blogs.data.msg
          }
         }
       })
     })
   }))
   .catch(err => console.log(err))
}

export function getHomepage() {
  return axios.all([
    axios.get(`http://${DOMAIN}/api/unsecure/getTrendingBlogs/0/5`), //get trending tags
    axios.get(`http://${DOMAIN}/api/unsecure/getLatestTrendingBloggers`),
    axios.get(`http://${DOMAIN}/api/unsecure/getBlogsByCategory/1/0/4`),
    axios.get(`http://${DOMAIN}/api/unsecure/getBlogsByCategory/2/0/4`),
    axios.get(`http://${DOMAIN}/api/unsecure/getBlogsByCategory/3/0/4`),
    axios.get(`http://${DOMAIN}/api/unsecure/getBlogsByCategory/4/0/4`)
  ])
   .then(axios.spread((tags, bloggers, food, fashion, travel, tech) => {
     return new Promise((res, rej) => {
       res({
         data: {
           msg: {
            tags: tags.data.msg,
            bloggers: bloggers.data.msg,
            blogs: {
              food: food.data.msg,
              fashion: fashion.data.msg,
              travel: travel.data.msg,
              tech: tech.data.msg
            }
          }
         }
       })
     })
   }))
   .catch(err => console.log(err))
}