-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom fetch som returnerer data: [] dersom 204
- Loading branch information
Showing
18 changed files
with
271 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const customFetch = async <T>(url: string, options: RequestInit): Promise<T> => { | ||
const response = await fetch(url, options); | ||
if (response.status === 204) { | ||
return [] as T; | ||
} | ||
const data: T = await response.json(); | ||
|
||
console.log("custom fetch url: ", url); | ||
if (url.includes("/tilgang")) { | ||
console.log("returnerer custom boio", {data, status: response.status}); | ||
return {data, status: response.status} as T; | ||
} | ||
|
||
return data as T; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.