Releases: swlkr/req
🐈 📦 better timeouts and you
I had a problem where sending "{}" returned some unexpected results sometimes, so xhr.send()
will only send a body if there is one.
I also decided to use yarn even though there's only two dependencies for testing and zero runtime dependencies.
This release also marks the first release where timeouts are handled correctly by not relying on ontimeout
but instead using setTimeout()
Broken tests
- Made the decision to go ahead and set any POST, PUT or PATCH bodies to {} when they're passed in as null
This happens for a decent reason. When xhr.send()
is called, instead of JSON.stringify(null) -> "null"
or JSON.stringify(undefined) -> "undefined"
, instead it's JSON.stringify({}) -> "{}"
as the body of the request
Requests are data
2.0.0! Requests as data
The whole api has changed. Http requests are just js objects now. Which is a good thing for a few reasons.
- The functions that operate on them in the library are now pure functions, meaning it was easier for me to focus on and test potential invalid data than it was before.
- The "arguments" are now named, I mean if you consider a js object as one argument naming arguments.
- It should be easier to wrap this library since the data coming into it is just that: data.
Initial commit
This is the first release of req. Despite the relatively small number of commits (two), this lib is currently used in production.
This library effectively acts an easier to use wrapper around xmlhttprequest which allows you to send json using promises to a server very easily.
The api will not change in the future. New functions might be added, but that's about it.
Enjoy 1.0.0!