Closed x1B closed 7 years ago
Implemented on master
(v0.5.0
).
init
options for fetch
can now globally be passed to the HAL HTTP client's create
function or for each request using one of the HTTP functions (get
, post
, ...) or the follow API. Set all options that should be passed to fetch
on fetchInit
of the options object. Available options can be found here. The keys method
, headers
and body
will be removed, since their values are controlled directly by the HAL HTTP client.
Example 1:
const hal = halHttp.create( {
headers: { 'accept-language': 'de' },
fetchInit: {
mode: 'cors'
}
} );
Example 2:
const promise = hal.get( url( '/resource' ), {
fetchInit: {
cache: 'no-store'
}
} );
Global init options will be merged with init options passed to one of the API methods, were the latter will win a collision.
For example to support CORS requests with an authorization cookie, the hal client should allow clients to specify fetch request options such as
credentials
.It might be useful to group options by category ("safe", "unsafe", "all").