NuxtN
Nuxt4y ago
Mr XQ

Best practice to store API end points

In nuxt2 I used Axios and store my end points under
services/api.js
example :
api.js:
export default ($apiClient) => ({
  fetchBlog() {
    return $apiClient.$get("/blog");
  },

  latestPosts(test) {
    return $apiClient.$get("test");
  },

and I use it inside pages like this:
index.js:
const blog= await this.$api.fetchBlog()

What's the best way to store and use API endpoints in nuxt3?
thank you.
Was this page helpful?