fix https error
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
// api.js
|
||||
export async function apiRequest(url, payload = {}, method = 'POST') {
|
||||
const res = await fetch(url, {
|
||||
method: method,
|
||||
const finalUrl = new URL(url, window.location.origin).toString();
|
||||
|
||||
const res = await fetch(finalUrl, {
|
||||
method,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
@@ -14,5 +16,6 @@ export async function apiRequest(url, payload = {}, method = 'POST') {
|
||||
const text = await res.text();
|
||||
throw new Error(`HTTP ${res.status}: ${text}`);
|
||||
}
|
||||
|
||||
return res.json();
|
||||
}
|
||||
Reference in New Issue
Block a user