Skip to content

Commit

Permalink
Add cache parameter to queryAPI function
Browse files Browse the repository at this point in the history
  • Loading branch information
n2o committed Nov 23, 2024
1 parent 14624af commit 6ed2e0e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export * from "@/models"
* @param method The HTTP method to use.
* @param token The token to use for authentication. Defaults to a Strapi API token.
* @param apiUrl The API URL to the Strapi Backend.
* @param cache The cache mode to use.
*/
export async function queryAPI<T>([
path,
Expand All @@ -26,7 +27,8 @@ export async function queryAPI<T>([
token = process.env.NEXT_PUBLIC_STRAPI_API_TOKEN ||
process.env.STRAPI_API_TOKEN,
apiUrl = process.env.NEXT_PUBLIC_STRAPI_API_URL || process.env.STRAPI_API_URL,
]: [string, any?, string?, string?, string?]): Promise<
cache = "no-cache",
]: [string, any?, string?, string?, string?, RequestCache?]): Promise<
StrapiResponse<T> | undefined
> {
const headers: Headers = {
Expand All @@ -38,6 +40,7 @@ export async function queryAPI<T>([
method: method ? method : body ? "POST" : "GET",
headers,
body: body ? JSON.stringify(body) : undefined,
cache,
})

if (result.ok) {
Expand Down

0 comments on commit 6ed2e0e

Please sign in to comment.