Skip to content

Commit 9e87cb4

Browse files
authored
fix: use fetchJsonLd for expanding errors (#352)
1 parent 1878c70 commit 9e87cb4

File tree

4 files changed

+231
-255
lines changed

4 files changed

+231
-255
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2.5.5
4+
5+
* Hydra: use `fetchJsonLd` when expanding an error (to use authorization header)
6+
37
## 2.5.4
48

59
* Fix sent `FormData` when a value is an object or an array (use JSON)

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"enzyme": "^3.10.0",
2626
"enzyme-adapter-react-16": "^1.14.0",
2727
"eslint": "^7.14.0",
28-
"eslint-config-prettier": "^6.3.0",
28+
"eslint-config-prettier": "^7.0.0",
2929
"eslint-plugin-import": "^2.14.0",
3030
"eslint-plugin-jsx-a11y": "^6.1.2",
3131
"eslint-plugin-markdown": "^1.0.1",
@@ -63,9 +63,9 @@
6363
]
6464
},
6565
"dependencies": {
66-
"@api-platform/api-doc-parser": "^0.11.0",
66+
"@api-platform/api-doc-parser": "^0.12.0",
6767
"history": "^4.7.2",
68-
"jsonld": "^1.2.1",
68+
"jsonld": "^3.2.0",
6969
"lodash.isplainobject": "^4.0.6",
7070
"prop-types": "^15.6.2",
7171
"react-admin": "^3.0.0"

src/hydra/fetchHydra.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
fetchJsonLd,
44
getDocumentationUrlFromHeaders,
55
} from '@api-platform/api-doc-parser';
6-
import { promises } from 'jsonld';
6+
import jsonld from 'jsonld';
77

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

26-
return fetchJsonLd(url, {
27-
...options,
28-
headers: requestHeaders,
29-
}).then((data) => {
26+
const authOptions = { ...options, headers: requestHeaders };
27+
28+
return fetchJsonLd(url, authOptions).then((data) => {
3029
const status = data.response.status;
3130

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

36-
return promises
35+
return jsonld
3736
.expand(body, {
3837
base: getDocumentationUrlFromHeaders(data.response.headers),
38+
documentLoader: (input) => fetchJsonLd(input, authOptions),
3939
})
4040
.then((json) => {
4141
return Promise.reject(

0 commit comments

Comments
 (0)