tanbal-hooks 1.0.0 → 1.0.2
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
|
-
import
|
|
2
|
+
import { request } from 'tanbal-utils';
|
|
3
3
|
|
|
4
4
|
const useDataManager = (url) => {
|
|
5
5
|
const [data, setData] = useState([]);
|
|
@@ -12,7 +12,7 @@ const useDataManager = (url) => {
|
|
|
12
12
|
) => {
|
|
13
13
|
try {
|
|
14
14
|
setStatus('loading');
|
|
15
|
-
const result = await
|
|
15
|
+
const result = await request(url);
|
|
16
16
|
setData(result.data);
|
|
17
17
|
setStatus('loaded');
|
|
18
18
|
successCallback(result.data);
|
|
@@ -34,7 +34,7 @@ const useDataManager = (url) => {
|
|
|
34
34
|
finallyCallback = () => {},
|
|
35
35
|
) => {
|
|
36
36
|
try {
|
|
37
|
-
const result = await
|
|
37
|
+
const result = await request(url, {
|
|
38
38
|
method: 'POST',
|
|
39
39
|
headers: {
|
|
40
40
|
'Content-Type': 'application/json',
|
|
@@ -63,7 +63,7 @@ const useDataManager = (url) => {
|
|
|
63
63
|
) => {
|
|
64
64
|
|
|
65
65
|
try {
|
|
66
|
-
const result = await
|
|
66
|
+
const result = await request(`${url}/${id}`, {
|
|
67
67
|
method: 'PATCH',
|
|
68
68
|
headers: {
|
|
69
69
|
'Content-Type': 'application/json',
|
|
@@ -90,7 +90,7 @@ const useDataManager = (url) => {
|
|
|
90
90
|
finallyCallback = () => {},
|
|
91
91
|
) => {
|
|
92
92
|
try {
|
|
93
|
-
const result = await
|
|
93
|
+
const result = await request(url, {
|
|
94
94
|
method: 'PATCH',
|
|
95
95
|
headers: {
|
|
96
96
|
'Content-Type': 'application/json',
|
|
@@ -117,7 +117,7 @@ const useDataManager = (url) => {
|
|
|
117
117
|
finallyCallback = () => {},
|
|
118
118
|
) => {
|
|
119
119
|
try {
|
|
120
|
-
const result = await
|
|
120
|
+
const result = await request(`${url}/${id}`, {
|
|
121
121
|
method: 'DELETE',
|
|
122
122
|
headers: {
|
|
123
123
|
'Content-Type': 'application/json',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tanbal-hooks",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A collection of custom React and Next.js hooks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -29,6 +29,6 @@
|
|
|
29
29
|
"react": ">=18"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"tanbal-utils": "^1.0.
|
|
32
|
+
"tanbal-utils": "^1.0.2"
|
|
33
33
|
}
|
|
34
34
|
}
|