Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

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.