import axios from 'axios';
import { API_PREF } from './common';

const fetchCategories = () => {
  return axios
    .get(`/api/categories/list`)
    .then(function (response) {
      let { data } = response;
      let { categories } = data;
      return categories;
    })
    .catch(function (error) {
      // handle error
      console.log(error);
    })
    .finally(function () {
      // always executed
    });
};

export default fetchCategories;
