Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.5.5

* Hydra: use `fetchJsonLd` when expanding an error (to use authorization header)

## 2.5.4

* Fix sent `FormData` when a value is an object or an array (use JSON)
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"eslint": "^7.14.0",
"eslint-config-prettier": "^6.3.0",
"eslint-config-prettier": "^7.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-markdown": "^1.0.1",
Expand Down Expand Up @@ -63,9 +63,9 @@
]
},
"dependencies": {
"@api-platform/api-doc-parser": "^0.11.0",
"@api-platform/api-doc-parser": "^0.12.0",
"history": "^4.7.2",
"jsonld": "^1.2.1",
"jsonld": "^3.2.0",
"lodash.isplainobject": "^4.0.6",
"prop-types": "^15.6.2",
"react-admin": "^3.0.0"
Expand Down
12 changes: 6 additions & 6 deletions src/hydra/fetchHydra.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
fetchJsonLd,
getDocumentationUrlFromHeaders,
} from '@api-platform/api-doc-parser';
import { promises } from 'jsonld';
import jsonld from 'jsonld';

/**
* Sends HTTP requests to a Hydra API.
Expand All @@ -23,19 +23,19 @@ export default (url, options = {}) => {
requestHeaders.set('Authorization', options.user.token);
}

return fetchJsonLd(url, {
...options,
headers: requestHeaders,
}).then((data) => {
const authOptions = { ...options, headers: requestHeaders };

return fetchJsonLd(url, authOptions).then((data) => {
const status = data.response.status;

if (status < 200 || status >= 300) {
const body = data.body;
delete body.trace;

return promises
return jsonld
.expand(body, {
base: getDocumentationUrlFromHeaders(data.response.headers),
documentLoader: (input) => fetchJsonLd(input, authOptions),
})
.then((json) => {
return Promise.reject(
Expand Down
Loading