@haniffalab/cherita-react 0.1.11 → 0.1.12-dev.2023-12-05.b3b4991a
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/README.md +3 -3
- package/dist/utils/requests.js +10 -8
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -10,10 +10,10 @@ Install packages
|
|
|
10
10
|
npm i
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Create a ``.env`` file within ``sites/demo`` to store environment variables for Vite to use. Within it set ``
|
|
13
|
+
Create a ``.env`` file within ``sites/demo`` to store environment variables for Vite to use. Within it set ``REACT_APP_API_URL`` to the backend API url like
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
|
-
|
|
16
|
+
REACT_APP_API_URL=http://localhost:5000/api/
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Run the demo app
|
|
@@ -22,4 +22,4 @@ Run the demo app
|
|
|
22
22
|
npm run start-demo
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
The app will automatically reload when changes are made
|
|
25
|
+
The app will automatically reload when changes are made
|
package/dist/utils/requests.js
CHANGED
|
@@ -14,14 +14,16 @@ function fetchData(_x, _x2) {
|
|
|
14
14
|
function _fetchData() {
|
|
15
15
|
_fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(endpoint, params) {
|
|
16
16
|
var signal,
|
|
17
|
+
apiUrl,
|
|
17
18
|
response,
|
|
18
19
|
_args = arguments;
|
|
19
20
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
20
21
|
while (1) switch (_context.prev = _context.next) {
|
|
21
22
|
case 0:
|
|
22
23
|
signal = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
apiUrl = process.env.REACT_APP_API_URL;
|
|
25
|
+
_context.next = 4;
|
|
26
|
+
return fetch(new URL(endpoint, apiUrl), {
|
|
25
27
|
method: "POST",
|
|
26
28
|
mode: "cors",
|
|
27
29
|
headers: {
|
|
@@ -31,19 +33,19 @@ function _fetchData() {
|
|
|
31
33
|
body: JSON.stringify(params),
|
|
32
34
|
signal: signal
|
|
33
35
|
});
|
|
34
|
-
case
|
|
36
|
+
case 4:
|
|
35
37
|
response = _context.sent;
|
|
36
38
|
if (response.ok) {
|
|
37
|
-
_context.next =
|
|
39
|
+
_context.next = 7;
|
|
38
40
|
break;
|
|
39
41
|
}
|
|
40
42
|
throw response;
|
|
41
|
-
case
|
|
42
|
-
_context.next =
|
|
43
|
+
case 7:
|
|
44
|
+
_context.next = 9;
|
|
43
45
|
return response.json();
|
|
44
|
-
case 8:
|
|
45
|
-
return _context.abrupt("return", _context.sent);
|
|
46
46
|
case 9:
|
|
47
|
+
return _context.abrupt("return", _context.sent);
|
|
48
|
+
case 10:
|
|
47
49
|
case "end":
|
|
48
50
|
return _context.stop();
|
|
49
51
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haniffalab/cherita-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12-dev.2023-12-05.b3b4991a",
|
|
4
4
|
"author": "",
|
|
5
5
|
"license": "",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -73,5 +73,6 @@
|
|
|
73
73
|
"bugs": {
|
|
74
74
|
"url": "https://github.com/haniffalab/cherita-react/issues"
|
|
75
75
|
},
|
|
76
|
-
"homepage": "https://github.com/haniffalab/cherita-react#readme"
|
|
76
|
+
"homepage": "https://github.com/haniffalab/cherita-react#readme",
|
|
77
|
+
"prereleaseSha": "b3b4991a97753c397c5cae36cbb66686375f7298"
|
|
77
78
|
}
|