'Nuxtjs axios get status code from response from Rest API
I'm calling a Rest API that returns status codes. Some of them don't return Content in body. If i make in postman my calls i can get some status code like 202 Accepted, 200 OK... how can get it in Nuxtjs with axios.
Any help would be very appreciated.
My code:
async register() {
const response = await this.$axios.$post('register/', {
user: this.user,
})
console.log(response)
// this.$nuxt.refresh()
// this.status = response.status
// if (this.status === 'register success') {
// this.$router.push('/login/')
// }
}
and nothing show up :(
Solution 1:[1]
I think it should be "this.$axios.post". There is not such method as $post.
From the official docs:
axios.post('/user', {
firstName: 'Fred',
lastName: 'Flintstone'})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | aleksKamb |

