Summer Sale! All accounts are 50% off this week.

hcastillo's avatar

what is the best approach to have 'services' folder on vuejs

HI, i wonder how i could manage my services files, right now i have this way: http-client.js | my base axios config

import axios from "axios";

const httpClient = axios.create({
  baseURL: "/api", // required to handle the CSRF token
  withCredentials: true,
});

export default httpClient;

roles-service.js | example of my file

import httpClient from "./http-client";


export default function () {
  const getRoles = async ()=> {
    const { data } = await httpClient.get("roles");
    return data;
  };

  return {
    getRoles,
  };
}
0 likes
0 replies

Please or to participate in this conversation.