This repository was archived by the owner on Feb 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path@reststate.patch
More file actions
66 lines (59 loc) · 2.14 KB
/
Copy path@reststate.patch
File metadata and controls
66 lines (59 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
--- @reststate.ORIG/client/src/Resource.js 2021-01-12 08:45:25.000000000 +0100
+++ @reststate/client/src/Resource.js 2021-02-04 19:34:48.000000000 +0100
@@ -48,7 +48,7 @@
if (options.url) {
({ url } = options);
} else {
- url = `${this.name}?${getOptionsQuery(options)}`;
+ url = `${this.name}/?${getOptionsQuery(options)}`;
}
return this.api
@@ -58,7 +58,7 @@
}
find({ id, options } = {}) {
- const url = `${this.name}/${id}?${getOptionsQuery(options)}`;
+ const url = `${this.name}/${id}/?${getOptionsQuery(options)}`;
return this.api
.get(url)
@@ -69,14 +69,14 @@
where({ filter, options } = {}) {
const queryString = filterQueryString(filter);
return this.api
- .get(`${this.name}?${queryString}&${getOptionsQuery(options)}`)
+ .get(`${this.name}/?${queryString}&${getOptionsQuery(options)}`)
.then(extractData)
.catch(extractErrorResponse);
}
related({ parent, relationship = this.name, options }) {
const baseUrl = relatedResourceUrl({ parent, relationship });
- const url = `${baseUrl}?${getOptionsQuery(options)}`;
+ const url = `${baseUrl}/?${getOptionsQuery(options)}`;
return this.api
.get(url)
.then(extractData)
@@ -84,10 +84,10 @@
}
create(partialRecord) {
- const record = Object.assign({}, partialRecord, { type: this.name });
+ const record = Object.assign({}, { type: this.name }, partialRecord);
const requestData = { data: record };
return this.api
- .post(`${this.name}`, requestData)
+ .post(`${this.name}/`, requestData)
.then(extractData)
.catch(extractErrorResponse);
}
@@ -96,13 +96,13 @@
// http://jsonapi.org/faq/#wheres-put
const requestData = { data: record };
return this.api
- .patch(`${this.name}/${record.id}`, requestData)
+ .patch(`${this.name}/${record.id}/`, requestData)
.then(extractData)
.catch(extractErrorResponse);
}
delete({ id }) {
- return this.api.delete(`${this.name}/${id}`).catch(extractErrorResponse);
+ return this.api.delete(`${this.name}/${id}/`).catch(extractErrorResponse);
}
}