skolplattformen-backup/libs/api-skolplattformen/agentFetchWrapper.js

18 lines
309 B
JavaScript

module.exports = function agentDecorator(fetch, agent) {
fetch = fetch || window.fetch
async function fetchWrapper(url, opts) {
opts = opts || {}
// Prepare request
opts.agent = agent
// Actual request
const res = await fetch(url, opts)
return res
}
return fetchWrapper
}