Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default (url, options = {}) => {
const requestHeaders = options.headers || new Headers();
if (options.user && options.user.authenticated && options.user.token) {
requestHeaders.set('Authorization', options.user.token);
}
return fetchJsonLd(url, {
...options,
headers: requestHeaders,
}).then(data => {
const status = data.response.status;
if (status < 200 || status >= 300) {
return promises
.expand(data.body, {
base: getDocumentationUrlFromHeaders(data.response.headers),
})
.then(json => {
return Promise.reject(
new HttpError(
json[0]['http://www.w3.org/ns/hydra/core#description'][0][
'@value'
],