mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-10 17:24:21 +01:00
This commit is contained in:
parent
aaeff27ba6
commit
325feb4afb
5 changed files with 19 additions and 8 deletions
|
|
@ -93,10 +93,14 @@ export const fetchSyncPost = async (url: string, data?: any) => {
|
|||
return res2;
|
||||
};
|
||||
|
||||
export const fetchGet = (url: string, cb: (response: IWebSocketData | IEmoji[]) => void) => {
|
||||
export const fetchGet = (url: string, cb: (response: IWebSocketData | IObject | string) => void) => {
|
||||
fetch(url).then((response) => {
|
||||
return response.json();
|
||||
}).then((response: IWebSocketData) => {
|
||||
if (response.headers.get("content-type")?.indexOf("application/json") > -1) {
|
||||
return response.json();
|
||||
} else {
|
||||
return response.text();
|
||||
}
|
||||
}).then((response) => {
|
||||
cb(response);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue