Hint that using data
is wrong
#1000
Comments
Yay, i claimed issue 1000 |
I am still learning all the ins and outs of various libraries and indeed my code was adapted from an |
@jimmywarting I think this makes sense, but I would throw an Error because they're probably going to get one anyway when they try to use the undefined return value |
I don't think an error should be thrown... it's not what is happening in (mostly) any method where you are allowed to pass in a object, other options are just ignored. it has the risk to break things as it wouldn't be backwards compatible. You can get a request option from an arbitrary place that could include both We try to align us self with how the whatwg fetch works in the browser and the spec. we never know the true intention if the developer really meant to post the edit ups, i was talking about the Request constructor... totally forgot that it was about the But yea, a warning on the request constructor would also be helpful :P when i think about it |
@jimmywarting And oops for me, too... I was only thinking about
|
It's a good idea, but I'm not sure how far we should deviate from the original fetch spec. |
it's not like we are adding any new feature/method into fetch, it's just a way of helping/notifying that what you might be doing is wrong. such notification could easily be removed if we ever decide to ditch it again |
From time to time i see ppl using
data
instead ofbody
which is wrong.happened just recently in #481 (comment)
how do you feel about adding a little warning message that can only appear once. (kinda like node reports that you are using experimental apis)
I don't think it is uncommon to see those mistake happening when switching from different request libraries
axios
use data instead of body for example. I can admit that i have used data as well and wasted minutes trying to figure out what's wrongThe text was updated successfully, but these errors were encountered: