- {}} isActive={false} />
- {}} isActive={true} />
+ { }} isActive={false} />
+ { }} isActive={true} />
- {}} isActive={false} />
- {}} isActive={true} />
+ { }} isActive={false} />
+ { }} isActive={true} />
+
{}}
+ handleVoiceInput={() => { }}
onLengthChange={(e: string) => {
console.log(e);
}}
/>
- {}} placeholder="출발지를 입력하세요">
+ { }} placeholder="출발지를 입력하세요">
{}}
+ onClick={() => { }}
placeholder="도착지를 입력하세요"
value={destination}
onCancel={() => setDestination("")}
@@ -62,6 +96,14 @@ export default function Demo() {
+
+
+
+
불편한 길 제보가 완료되었습니다!
diff --git a/uniro_frontend/src/utils/fetch/fetch.ts b/uniro_frontend/src/utils/fetch/fetch.ts
new file mode 100644
index 0000000..20e44f4
--- /dev/null
+++ b/uniro_frontend/src/utils/fetch/fetch.ts
@@ -0,0 +1,54 @@
+export default function Fetch() {
+ const baseURL = import.meta.env.VITE_REACT_SERVER_BASE_URL;
+
+ const get = async (url: string, params?: Record): Promise => {
+ const paramsURL = new URLSearchParams(
+ Object.entries(params || {}).map(([key, value]) => [key, String(value)]),
+ ).toString();
+
+ const response = await fetch(`${baseURL}${url}?${paramsURL}`, {
+ method: "GET",
+ });
+
+ if (!response.ok) {
+ throw new Error(`${response.status}-${response.statusText}`);
+ }
+
+ return response.json();
+ };
+
+ const post = async (url: string, body?: Record): Promise => {
+ const response = await fetch(`${baseURL}${url}`, {
+ method: "POST",
+ body: JSON.stringify(body),
+ });
+
+ if (!response.ok) {
+ throw new Error(`${response.status}-${response.statusText}`);
+ }
+
+ return response.json();
+ };
+
+ const put = async (url: string, body?: Record): Promise => {
+ const response = await fetch(`${baseURL}${url}`, {
+ method: "PUT",
+ body: JSON.stringify(body),
+ });
+
+ if (!response.ok) {
+ throw new Error(`${response.status}-${response.statusText}`);
+ }
+
+ return response.json();
+ };
+
+ return {
+ get,
+ post,
+ put,
+ };
+}
+
+const { get, post, put } = Fetch();
+export { get as getFetch, post as postFetch, put as putFetch };