node-js-libs / curlrequest

A cURL wrapper
MIT License
184 stars 44 forks source link

Provide response code #65

Open markg85 opened 6 years ago

markg85 commented 6 years ago

Hi,

Perhaps this is already possible, but then i apparently didn't find it.. Would it be possible to extend the API to provide the response code? I'm thinking of a way like:

curl.request(options, function (err, data, code) { //.. });

Meta (the current third argument) would move to the fourth position.

There are some web services out there that use response codes to tell the user something. there seems to be some deviation in how services handle that.

For example, take the TVMaze API. You can request information about series on that API, but if you request something of a series it doesn't know it returns a 404. A very valid not found response. Then there are other services out there that to output a 200 OK code, but with a (json) output indicating that whatever was queried for was not found.

Cheers, Mark