fix: properly implement "With credential" in the API console
This commit is contained in:
parent
d8d0ad0c00
commit
19e5d28cf7
@ -24,6 +24,7 @@ export const api = ((
|
|||||||
endpoint: string,
|
endpoint: string,
|
||||||
data: Record<string, any> = {},
|
data: Record<string, any> = {},
|
||||||
token?: string | null | undefined,
|
token?: string | null | undefined,
|
||||||
|
useToken: boolean = true,
|
||||||
) => {
|
) => {
|
||||||
pendingApiRequestsCount.value++;
|
pendingApiRequestsCount.value++;
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ export const api = ((
|
|||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
credentials: "omit",
|
credentials: "omit",
|
||||||
cache: "no-cache",
|
cache: "no-cache",
|
||||||
headers: authorization ? { authorization } : {},
|
headers: authorization && useToken ? { authorization } : {},
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
const body = res.status === 204 ? null : await res.json();
|
const body = res.status === 204 ? null : await res.json();
|
||||||
|
@ -71,7 +71,8 @@ function send() {
|
|||||||
os.api(
|
os.api(
|
||||||
endpoint.value as keyof Endpoints,
|
endpoint.value as keyof Endpoints,
|
||||||
requestBody,
|
requestBody,
|
||||||
requestBody.i || (withCredential.value ? undefined : null),
|
null,
|
||||||
|
withCredential.value,
|
||||||
).then(
|
).then(
|
||||||
(resp) => {
|
(resp) => {
|
||||||
sending.value = false;
|
sending.value = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user