gis 편집
This commit is contained in:
@@ -101,6 +101,32 @@ export const postData = async (url: string, data: object): Promise<any> => {
|
||||
}
|
||||
};
|
||||
|
||||
export const postRawJson = async (url: string, data: object): Promise<any> => {
|
||||
const res = await fetch(resolveApiUrl(url), {
|
||||
method: "POST",
|
||||
headers: withSiteIdHeaders({
|
||||
"Content-Type": "application/json",
|
||||
}),
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (res.status === 401) {
|
||||
handleUnauthorizedResponse();
|
||||
}
|
||||
|
||||
const text = await res.text();
|
||||
const body = text && text.trim() ? JSON.parse(text) : null;
|
||||
if (!res.ok) {
|
||||
const message =
|
||||
body?.message ??
|
||||
`Failed to post data: ${res.status} ${res.statusText}`;
|
||||
const error = new Error(message) as Error & { status?: number; body?: any };
|
||||
error.status = res.status;
|
||||
error.body = body;
|
||||
throw error;
|
||||
}
|
||||
return body;
|
||||
};
|
||||
|
||||
const parseDownloadFileName = (contentDisposition: string | null) => {
|
||||
if (!contentDisposition) return undefined;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user