-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi-2.js
More file actions
33 lines (31 loc) · 1 KB
/
api-2.js
File metadata and controls
33 lines (31 loc) · 1 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
// ! =======================================================================================
// ! ngrok 을 모름..
// ! =======================================================================================
import axios from "axios";
const iDontKnowNgrok = async (method, path, data, jwt) => {
const headers = {
Authorization: jwt,
"Content-Type": "application/json",
};
const baseUrl = "http://127.0.0.1:8000/";
const fullUrl = `${baseUrl}${path}`;
if (method === "get" || method === "delete") {
return axios[method](fullUrl, { headers });
} else {
return axios[method](fullUrl, data, { headers });
}
};
export const getStoreAxios = (form) =>
iDontKnowNgrok("get", "v1/stores/all/", form);
// todo: data 를 넘겨야 함...
export const getStore = (setState) => {
fetch("http://127.0.0.1:8000/v1/stores/all/", {
method: "GET",
})
.then((resp) => resp.json())
.then((data) => {
setState(data);
// console.log(data);
})
.catch((error) => alert(error));
};