Having just started working with Nuxt.js
, I encountered an unusual issue. There is an endpoint in my backend API that allows users to reset their password by sending a token
along with a new password
.
Although the request is being sent correctly and the server responds with the expected data:
https://i.sstatic.net/gAWsq.png
The problem arises on the Nuxt.js
side when handling the response data.
To manage all HTTP requests using axios, I have implemented a class like this:
class WebAPI {
// $axios is the instance used in the Nuxt.js context
constructor($axios) {
this.$http = $axios;
}
async call(config) {
try {
const result = await this.$http(config);
console.log(result);
// ...
} catch( e) {
// ...
}
}
}
And I utilize this class as follows:
const data = {
token,
new_password
};
const options = {
method: 'POST',
url : '/reset-password',
data
};
return this.webApi.call(options);
However, as you can see, the issue lies within the WebAPI
service where the axios response is showing as undefined
.
It is also important to note that the same WebAPI
class functions perfectly for other API requests made in the application.
Can anyone assist with this matter? Is there anything that stands out as incorrect?