Skip to main content

Config

When define your API and endpoints you can give them some default config which are cascaded down to requests:

const api = new Api({
name : "My Backend",
baseUrl: "http://localhost:5000/v1",
config: {
retry: 2,
headers: {
"Cool-Header": "hello!"
}
}
});

export const fetchData = api.endpoint()
.build({
id: "fetch_data",
config: {
retry: false,
cache: 1000 * 60 * 15 // 15 mins
}
})

Properties

Request config properties:

NameTypeDefaultUsage
retrynumber or falsefalseHow many times should the request be retried if there was a non-network error?
cachenumber or booleanfalseIf a number, how long to cache response for in ms
headersRecord<string, stringundefinedBase headers for the request