简体   繁体   中英

Is response.ok true for any 2xx HTTP status?

Is response.ok true for any 2xx HTTP status? If so, why? Shouldn't it be only for a 200 status code?

The fetch specs state, that a response returns true if the response status has an OK status .

An ok status is a status in the range 200 to 299, inclusive.

The reason for this seems to, that a 2xx status yields a successfull response, which is pretty common for 201, 206 etc. in the RESTful world.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM