
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
bivrost-fetch-adapter
Advanced tools
Adapter for browser's native fetch function.
yarn add bivrost-fetch-adapter
With Bivrost:
import DataSource from 'bivrost/data/source';
import bivrostApi from 'bivrost/http/api';
import fetchAdapter from 'bivrost-fetch-adapter';
const api = bivrostApi({
host: 'localhost',
adapter: fetchAdapter(),
});
class UsersDataSource extends DataSource {
static api = {
loadAll: api('GET /users'),
};
loadUsers(filters) {
return this.invoke('loadAll', filters);
}
}
Direct calls:
import fetchAdapter from 'bivrost-fetch-adapter';
const api = fetchAdapter();
const options = {
method: 'GET',
query: {
groupId: 10,
},
headers: {
'Content-Type': 'application/json',
},
};
api('/users', options) // /users?groupId=10
.then(json => {
// ...
})
.catch(response => {
// ...
});
const options = {
method: 'POST',
body: {
name: 'kek',
},
headers: {
'Content-Type': 'application/json',
},
};
api('/user/1', options)
.then(json => {
// ...
})
.catch(response => {
// ...
});
import fetchAdapter from 'bivrost-fetch-adapter';
const api = fetchAdapter({
// default options for each request with created adapter
options: {
mode: 'cors',
redirect: 'follow',
},
});
Available options:
import fetchAdapter from 'bivrost-fetch-adapter';
const api = fetchAdapter({
interceptors: {
// takes Request instance as argument
request: request => {
// ...
},
error: error => {
// ...
},
// takes Response instance as argument
response: response => {
// ...
},
},
});
Request object documentation - https://developer.mozilla.org/en-US/docs/Web/API/Request
Response object documentation - https://developer.mozilla.org/en-US/docs/Web/API/Response
NOTE: If there is a network error or another reason why the HTTP request couldn't be fulfilled, the fetch() promise will be rejected with a reference to that error.
Interceptor example:
import fetchAdapter from 'bivrost-fetch-adapter';
const api = fetchAdapter({
interceptors: {
request: request => {
request.headers.set('Content-Type', 'application/json');
request.headers.set('access_token', Auth.accessToken);
return request;
},
error: error => Promise.reject(error);
response: response => Promise.resolve(response)
}
});
Github whatwg-fetch - https://github.com/github/fetch
Bivrost allows to organize a simple interface to asyncronous APIs.
FAQs
Bivrost adapter using browser's native fetch function
The npm package bivrost-fetch-adapter receives a total of 5 weekly downloads. As such, bivrost-fetch-adapter popularity was classified as not popular.
We found that bivrost-fetch-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.