0

How can I use this link and get information in vue.js

http://localhost:2020/rest-password${token}&id=${data._id} 

My code is:

const submit = async () => { console.log('e'); try { const user = await axios.post(`http://localhost:2020/rest-password${token}&id=${data._id}`,{ password:password.value }) console.log(user, "sss"); router.push('/log') } catch (e) { error.value = e.response } } 

I tried to get information from Backend, but I think the method is incorrect

When I put the link in Postman I can get it

http://localhost:2020/rest-password?token=a3224e69cba1be642b97c2ab7265b607ff9d8052c253cbc221cfee80327d&id=6226fa4a2ff1d47fa2e732d7 
1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.