[Vuejs]-I'm trying to reset my password in vue.js

0👍

Assuming token contains only the token value (e.g., a322⋯327d), the token is incorrectly appended in the URL string:

const user = await axios.post(`http://localhost:2020/rest-password${token}&id=${data._id}`, {⋯})
                                                                  ^^^^^^^^

For example, if token were abcd and data._id were 1234, the result would be:

const user = await axios.post(`http://localhost:2020/rest-passwordabcd&id=1234`, {⋯})

Notice how the token value has no delimiters in the string, and just appears in the middle. Specifically, it’s missing token= before the token value; and the ? separator before the query parameters.

Solution

The string should be formatted like this:

const user = await axios.post(`http://localhost:2020/rest-password?token=${token}&id=${data._id}`, {⋯})
                                                                     👆

As an aside, rest-password seems to contain a typo, assuming rest should be reset.

Leave a comment