[Vuejs]-Wait for a request in axios

1πŸ‘

First of all that JSON.parse is not working as I would expect

See the documentation.

response is not a string of JSON.

It is an object. The response body is available through the data property. If the body is JSON, it will be parsed automatically and the result assigned to data.

Also, the use of finally to be sure that the first request has finished is correct, or it is not?

No. finally runs when the promise is settled β€” no matter if it was successful or not.

You almost certainly don’t want to be carrying on if there was an error so you should be using then.

Do everything in your existing then callback.

Leave a comment