0

As part of learning Vue3 I am trying to piece together code that will mock API calls using Axios and a local Json file. However I am getting a 404 when accessing the file and suspect the route is not setup correctly.

The data files are in my root folder and I have the following in the routes.json file in the root of the project

{
  "/api/*": "/$1",
  "/hero": "/heroes",
  "/reset": "/reset"
}

I have no reference to the API in the router config (vueRouter) and not sure if needed?.

When I call the ../api/heros (file) I get redirected to my page not found handler.

 {
    path: "/:catchAll(.*)",
    name: "NotFound",
    component: PageNotFound,
    meta: {
      requiresAuth: false
    }
  },

I am not sure my routes.js and router/index.js affect each other?

Project folder

Expectation: I can navigate to the JSON data in the browser and also use this in Axios

kissu
  • 40,416
  • 14
  • 65
  • 133
  • You use the tag `axios-mock-adapter`, but I do not see that anywhere in the code you are sharing… – Gabe Nov 27 '22 at 17:21

0 Answers0