mirror of https://github.com/sylv/micro.git
parent
af01384a1a
commit
ec071a47f6
|
@ -20,7 +20,7 @@ export const apiUri = isServer ? process.env.API_URL : `/api`;
|
|||
export async function http(pathOrUrl: string, options?: RequestInit): Promise<Response> {
|
||||
const hasProtocol = pathOrUrl.startsWith('http');
|
||||
const isAbsolute = pathOrUrl.startsWith('/');
|
||||
const url = hasProtocol ? pathOrUrl : isAbsolute ? `${apiUri}${pathOrUrl}` : `${apiUri}/${pathOrUrl}`;
|
||||
const url = hasProtocol || isAbsolute ? pathOrUrl : `${apiUri}${pathOrUrl}`;
|
||||
const response = await fetch(url, options);
|
||||
if (!response.ok) {
|
||||
const clone = response.clone();
|
||||
|
|
Loading…
Reference in New Issue