• Now all data be ready for publish, We had made our blog alive now. Haha.



  • These days CCP GFW blocked all the IPs from US and when I switch my IP in google Cloud, the disk data cannot be restore again. I have to restart my blog totally, Now the website is still building…



Q: Get header response Nuxt Axios – Stack Overflow

Vue PingBook 3 weeks ago (10-23) 12 0

Question

:
I’ve problem with nuxt overwrite axios response.
Firstly i have try axios in empty nodejs project to check if resource is available.

axios
.head(
https://needtocheckthislink’
)
.then(function(response) {
// here code 200
console.log(response.status);
})
.catch(function(error) {
// Some errors 403 / 404
console.log(error.response.status);
});

It’s work fine but in nuxt i can’t get response.data from my request.
Nuxt provide error code but i can’t explain it.

// for 403
Error: “Network Error”
NuxtJS 2

createError

handleError

// for 404
Error: “Request failed with status code 404”
NuxtJS 3

createError

settle

handleLoad

How can i work correctly with this request ?

Answer

:
Because i wasn’t sure this solution was on client side : Axios
I have use basic http header request.

let client = new XMLHttpRequest();
client.open(“GET”, “http://testUrl”, true);
client.send();
client.onreadystatechange = function() {
if(this.readyState == this.HEADERS_RECEIVED) {
if(client.status === 200){
console.log(“res 200”);
}
else if(client.status === 404){
console.log(“err 404”);
}
else if(client.status === 0){
console.log(“forbiden”)
}
client.abort();
}
}




Copyright from PingBook Blog, If not specified, they are original. This site uses BY-NC-SAProtocol authenticated.
For reprinting, please indicate the link of the original text:Q: Get header response Nuxt Axios – Stack Overflow
LIKE (0)
[1725641479@qq.com]
SHARE (0)
PingBook
Author:
We create, We sharing! Tag every value data your sharing
Submit comments
Cancel comments
emoji picture bold strikethrough center italic check in

Hi,you need to provide your name and email adress!

  • Name (Required)
  • Email (Required)
  • Website