Skip to content

Commit

Permalink
feat: support timeout (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuong Tran committed Sep 9, 2020
1 parent 646c0a4 commit b3157c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ const { data } = await hera({
## 🚀 API

```ts
interface Options {
url?: string;
headers?: any;
timeout?: number;
}

hera({
query: string;
variables?: any;
Expand All @@ -143,7 +149,7 @@ hera({
headers: {
token: 'Fv0761DZcunUr0dKBc4oo5k55jJchwqu',
'Content-Type': 'application/json'
}
},
}
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function formatQuery(query: string, variables: any): string {
interface Options {
url?: string;
headers?: any;
timeout?: number;
}


Expand Down Expand Up @@ -45,6 +46,7 @@ const hera = async ({
},
{
headers: options.headers,
timeout: options.timeout || 0,
},
);
return res.data;
Expand Down

0 comments on commit b3157c0

Please sign in to comment.