diff --git a/README.md b/README.md index 82d29b8..af429c4 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,12 @@ const { data } = await hera({ ## 🚀 API ```ts +interface Options { + url?: string; + headers?: any; + timeout?: number; +} + hera({ query: string; variables?: any; @@ -143,7 +149,7 @@ hera({ headers: { token: 'Fv0761DZcunUr0dKBc4oo5k55jJchwqu', 'Content-Type': 'application/json' - } + }, } ``` diff --git a/package.json b/package.json index 44cdcb8..87bb185 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@103cuong/hera-js", - "version": "0.4.2", + "version": "0.4.3", "description": "👩🏼‍💻 Simple and lightweight GraphQL client.", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/src/index.ts b/src/index.ts index cbddaf4..976d9e3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,6 +17,7 @@ function formatQuery(query: string, variables: any): string { interface Options { url?: string; headers?: any; + timeout?: number; } @@ -45,6 +46,7 @@ const hera = async ({ }, { headers: options.headers, + timeout: options.timeout || 0, }, ); return res.data;