matthew-andrews / isomorphic-fetch

Isomorphic WHATWG Fetch API, for Node & Browserify
MIT License
6.95k stars 289 forks source link

res.status === 204 is not included in res.ok ? #114

Open littlee opened 7 years ago

littlee commented 7 years ago

I send a DELETE request to the server, and it return 204, without any content 2016-11-12 11 32 13

fetch(url, {
  method: 'DELETE'
})
.then(function(res){
  alert(res.status) //204
  if(res.ok) 
    alert('OK') // never called
  }
})
jeffmobiles commented 6 years ago

followup

leggsimon commented 6 years ago

Do you get the same behaviour if fetching from https://getstatuscode.com/204 with the GET method? I've tried that and it appears to be working fine

littlee commented 6 years ago

notice that I was using DELETE method, and I tried to hit https://getstatuscode.com/204 , it returns 403 wx20180823-121454

dpdhruv commented 3 years ago

any updates on this one? it throws JSON end input error if server returns null body status i.e 204. Are they converting response to JSON internally or something ?