Home > Net >  how solve 404 error in axios post request in vue?
how solve 404 error in axios post request in vue?

Time:10-22

i want send request to an api but i have 404 erro and i have nothing in network can you help me? my code:

    loginMethod() {
  const config = {
    userName: "[email protected]",
    password: "1234test",
  };
  return new Promise((resolve) => {
    ApiService.post("api/authentication/login", config)
      .then(({ data }) => {
        console.log(data);

        resolve(data);
      })
      .catch(({ response }) => {
        console.log(response);
      });
  });
},

and ApiService function:

  post(resource, params) {
console.log(params);
const headers = {
  "E-Access-Key": "bb08ce8",
};
return Vue.axios.post(`${resource}`, params, { headers: headers });

},

CodePudding user response:

"404" means your API Endpoint is not found . You need to declare the location of your API Endpoint exactly. For example : http://localhost:8080/api/authentication/login. Mark this as answer if this solved your problem.

  • Related