Skip to content

Commit e88cfa7

Browse files
committed
[React] Improve fetch
1 parent c18e842 commit e88cfa7

File tree

2 files changed

+46
-26
lines changed

2 files changed

+46
-26
lines changed

templates/react-common/utils/dataAccess.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@ export function fetch(id, options = {}) {
2626
if (!json.violations) throw Error(error);
2727

2828
let errors = { _error: error };
29-
json.violations.map(
30-
violation => (errors[violation.propertyPath] = violation.message)
29+
json.violations.forEach(violation =>
30+
errors[violation.propertyPath]
31+
? (errors[violation.propertyPath] +=
32+
'\n' + errors[violation.propertyPath])
33+
: (errors[violation.propertyPath] = violation.message)
3134
);
3235

3336
throw new SubmissionError(errors);
37+
})
38+
.catch(() => {
39+
throw new Error(response.statusText);
3440
});
35-
});
41+
});
3642
}
3743

3844
export function mercureSubscribe(url, topics) {

yarn.lock

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
# yarn lockfile v1
33

44

5-
"@api-platform/api-doc-parser@^0.5.0":
6-
version "0.5.0"
7-
resolved "https://registry.yarnpkg.com/@api-platform/api-doc-parser/-/api-doc-parser-0.5.0.tgz#c8d2d860937d5c795577dec33f7914567f5ec9eb"
8-
integrity sha512-P5JwdVLji2nb/llO+usY6IGgkLNBcGsVFON7k3ube8uePz2KRrjyslKUsrmSKUW1aoUwSke9NXQUh600er8Ukg==
5+
"@api-platform/api-doc-parser@^0.7.2":
6+
version "0.7.2"
7+
resolved "https://registry.yarnpkg.com/@api-platform/api-doc-parser/-/api-doc-parser-0.7.2.tgz#c5ca5913fa6ee319016a635df5225e0db5ecc9ab"
8+
integrity sha512-FHzAldq1/ZZZhRyI8sgfxIrf3NtKLNgaW6P8Z12cjK3qWDuYCjsQZ1H2Z4WGZk0tGhDxA3lVJXcw4HHD5kjTrQ==
99
dependencies:
1010
babel-runtime "^6.23.0"
11-
jsonld "^0.4.11"
11+
jsonld "^1.5.0"
1212
lodash.get "^4.4.2"
13+
lodash.uniq "^4.5.0"
1314

1415
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.0.0-beta.35":
1516
version "7.0.0"
@@ -1911,11 +1912,6 @@ es-to-primitive@^1.2.0:
19111912
is-date-object "^1.0.1"
19121913
is-symbol "^1.0.2"
19131914

1914-
es6-promise@^2.0.0:
1915-
version "2.3.0"
1916-
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-2.3.0.tgz#96edb9f2fdb01995822b263dd8aadab6748181bc"
1917-
integrity sha1-lu258v2wGZWCKyY92KratnSBgbw=
1918-
19191915
escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
19201916
version "1.0.5"
19211917
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
@@ -3590,14 +3586,14 @@ json5@^0.5.1:
35903586
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
35913587
integrity sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=
35923588

3593-
jsonld@^0.4.11:
3594-
version "0.4.12"
3595-
resolved "https://registry.yarnpkg.com/jsonld/-/jsonld-0.4.12.tgz#a02f205d5341414df1b6d8414f1b967a712073e8"
3596-
integrity sha1-oC8gXVNBQU3xtthBTxuWenEgc+g=
3589+
jsonld@^1.5.0:
3590+
version "1.6.0"
3591+
resolved "https://registry.yarnpkg.com/jsonld/-/jsonld-1.6.0.tgz#faf968a35e47ababe5b79a0309ee67155a5a8832"
3592+
integrity sha512-gtbEplGXOgSrD7fP0vCmZoYX35MIQqFrpiMfJkEs9KwT7+bNzEd9y9gAUK8SGYXIYJISQCWNU5/eSDPKKxXeHw==
35973593
dependencies:
3598-
es6-promise "^2.0.0"
3599-
pkginfo "~0.4.0"
3600-
request "^2.61.0"
3594+
rdf-canonize "^1.0.2"
3595+
request "^2.88.0"
3596+
semver "^5.6.0"
36013597
xmldom "0.1.19"
36023598

36033599
jsprim@^1.2.2:
@@ -3710,6 +3706,11 @@ lodash.sortby@^4.7.0:
37103706
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
37113707
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
37123708

3709+
lodash.uniq@^4.5.0:
3710+
version "4.5.0"
3711+
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
3712+
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
3713+
37133714
lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.4, lodash@^4.17.5:
37143715
version "4.17.11"
37153716
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
@@ -3978,6 +3979,11 @@ node-fetch@^1.0.1:
39783979
encoding "^0.1.11"
39793980
is-stream "^1.0.1"
39803981

3982+
node-forge@^0.8.1:
3983+
version "0.8.2"
3984+
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.8.2.tgz#b4bcc59fb12ce77a8825fc6a783dfe3182499c5a"
3985+
integrity sha512-mXQ9GBq1N3uDCyV1pdSzgIguwgtVpM7f5/5J4ipz12PKWElmPpVWLDuWl8iXmhysr21+WmX/OJ5UKx82wjomgg==
3986+
39813987
node-int64@^0.4.0:
39823988
version "0.4.0"
39833989
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
@@ -4340,11 +4346,6 @@ pkg-dir@^2.0.0:
43404346
dependencies:
43414347
find-up "^2.1.0"
43424348

4343-
pkginfo@~0.4.0:
4344-
version "0.4.1"
4345-
resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.4.1.tgz#b5418ef0439de5425fc4995042dced14fb2a84ff"
4346-
integrity sha1-tUGO8EOd5UJfxJlQQtztFPsqhP8=
4347-
43484349
pluralize@^7.0.0:
43494350
version "7.0.0"
43504351
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777"
@@ -4450,6 +4451,14 @@ rc@^1.2.7:
44504451
minimist "^1.2.0"
44514452
strip-json-comments "~2.0.1"
44524453

4454+
rdf-canonize@^1.0.2:
4455+
version "1.0.3"
4456+
resolved "https://registry.yarnpkg.com/rdf-canonize/-/rdf-canonize-1.0.3.tgz#71dc56bb808a39d12e3ca17674c15f881cad648a"
4457+
integrity sha512-piLMOB5Q6LJSVx2XzmdpHktYVb8TmVTy8coXJBFtdkcMC96DknZOuzpAYqCWx2ERZX7xEW+mMi8/wDuMJS/95w==
4458+
dependencies:
4459+
node-forge "^0.8.1"
4460+
semver "^5.6.0"
4461+
44534462
read-pkg-up@^1.0.1:
44544463
version "1.0.1"
44554464
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02"
@@ -4631,7 +4640,7 @@ request-promise-native@^1.0.5:
46314640
stealthy-require "^1.1.0"
46324641
tough-cookie ">=2.3.3"
46334642

4634-
request@^2.61.0, request@^2.87.0:
4643+
request@^2.87.0, request@^2.88.0:
46354644
version "2.88.0"
46364645
resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef"
46374646
integrity sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==
@@ -4788,6 +4797,11 @@ self-closing-tags@^1.0.1:
47884797
resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
47894798
integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==
47904799

4800+
semver@^5.6.0:
4801+
version "5.7.0"
4802+
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b"
4803+
integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==
4804+
47914805
set-blocking@^2.0.0, set-blocking@~2.0.0:
47924806
version "2.0.0"
47934807
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"

0 commit comments

Comments
 (0)