Hello i’m new to this community and to javascript too.
I want to create a function that will take a url as argument and return the htpp status code of that website. (404, 200, 403 etc).
function getStatus(url){
var http = new XMLHttpRequest();
http.open('HEAD',url, false);
http.send();
return http.status;
}
I tried this but isn’t working. Is there something else better than this that i can do i vanilla javascript.
Ps. The link that it says this question is already asked is not waht i wanted