create-catalyst-app-internal 0.0.1-beta.18 → 0.0.1-beta.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/common/api.js +12 -23
package/package.json
CHANGED
package/templates/common/api.js
CHANGED
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
let finalUrl = baseURL + url
|
|
1
|
+
const fetchFunction = (url, options) => {
|
|
2
|
+
let baseURL = process.env.API_URL
|
|
3
|
+
let finalUrl = baseURL + url
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
// Request Interceptor - modify request here
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const parsedResponse = await response.json()
|
|
15
|
-
// Response Interceptor - modify response here
|
|
16
|
-
return parsedResponse
|
|
7
|
+
return fetch(finalUrl, options)
|
|
8
|
+
.then(response => {
|
|
9
|
+
return response.json().then(parsedResponse => {
|
|
10
|
+
// Response Interceptor - modify response here
|
|
11
|
+
return parsedResponse
|
|
12
|
+
})
|
|
17
13
|
})
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
get: fetchFunction,
|
|
21
|
-
post: fetchFunction,
|
|
22
|
-
delete: fetchFunction,
|
|
23
|
-
patch: fetchFunction,
|
|
24
|
-
put: fetchFunction,
|
|
25
|
-
}
|
|
26
14
|
}
|
|
27
|
-
|
|
15
|
+
|
|
16
|
+
export default fetchFunction
|