Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Get the Status Code of a Fetch HTTP Response

// 1.Get the API.
// 2.Check if we resolved the promise.
// 3.Condition of "else" will return the status of our promise.
fetch("https://example/api")
	.then(res => {
  		if(res.ok){
         return res.json()
        }else{
         return Promise.reject(res.status)
    	  }
})
 
PREVIOUS NEXT
Tagged: #Get #Status #Code #Fetch #HTTP #Response
ADD COMMENT
Topic
Name
1+2 =