-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gqob
committed
Nov 6, 2023
1 parent
86016c2
commit e46c246
Showing
8 changed files
with
92 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { FetchURL, Method } from '@CrxInterface'; | ||
|
||
class FetchLM { | ||
baseURL: string | ||
constructor () { | ||
this.baseURL = import.meta.env.VITE_HOME; | ||
} | ||
async get (URL: FetchURL, parameter?: string) { | ||
parameter = parameter ? `/${parameter}` : ''; | ||
const response = await fetch(this.baseURL + URL + parameter, { | ||
method : Method.GET, | ||
}); | ||
if (!response.ok) throw response; | ||
return await response.json(); | ||
} | ||
async post (URL: FetchURL, body?: string) { | ||
const response = await fetch(this.baseURL + URL, { | ||
method : Method.POST, | ||
body : body | ||
}); | ||
if (!response.ok) throw response; | ||
return await response.json(); | ||
} | ||
async put (URL: FetchURL, body?: string) { | ||
const response = await fetch(this.baseURL + URL, { | ||
method : Method.PUT, | ||
body : body | ||
}); | ||
if (!response.ok) throw response; | ||
return await response.json(); | ||
} | ||
async delete (URL: FetchURL) { | ||
const response = await fetch(this.baseURL + URL, { | ||
method : Method.DELETE, | ||
}); | ||
if (!response.ok) throw response; | ||
return await response.json(); | ||
} | ||
} | ||
|
||
export const fetchLM = new FetchLM(); | ||
|
||
export const fetchUser = async () => { | ||
const res = await fetchLM.get(FetchURL.user); | ||
return res; | ||
} | ||
|
||
export const fetchProcesses = async () => { | ||
const result = await fetchLM.get(FetchURL.process); | ||
return result; | ||
} | ||
|
||
export const fetchProcess = async (processId: string) => { | ||
const result = await fetchLM.get(FetchURL.process, processId); | ||
return result; | ||
} | ||
|
||
export const putProcess = async (body: string) => { | ||
const result = await fetchLM.put(FetchURL.process, body); | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters