Search
 
SCRIPT & CODE EXAMPLE
 

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)
    	  }
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: innertext vs textcontent 
Javascript :: flutter access json object inside object 
Javascript :: what is data node in big data 
Javascript :: javascript add days to date 
Javascript :: cypress click link contains text 
Javascript :: sort javascript array 
Javascript :: throttling function in javascript 
Javascript :: vue max characters html input 
Javascript :: vue on click router push not working 
Javascript :: string to ascii code js 
Javascript :: maximum sum subarray javascript 
Javascript :: nodejs wait event loop to finish 
Javascript :: tofixed currency in js 
Javascript :: jquery value of input 
Javascript :: jquery insertafter 
Javascript :: get screen resolution jquery 
Javascript :: how to import your external js 
Javascript :: javascript truncate array 
Javascript :: jquery migrate 
Javascript :: javascript assert 
Javascript :: minecraft lang file 
Javascript :: javascript write text 
Javascript :: import all images from folder reactjs 
Javascript :: latitude and longitude distance calculate in node js 
Javascript :: truncate a string 
Javascript :: Getting Elements by Class Name 
Javascript :: node convert buffer to string 
Javascript :: axios timeout post example 
Javascript :: xmlhttprequest pass parameters post 
Javascript :: javascript video feed 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =