Skip to content

Commit

Permalink
chore(docs): mention setHeader (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
stphnnnn authored Aug 3, 2020
1 parent ad5a403 commit 3f51dab
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,24 @@ main().catch((error) => console.error(error))

[TypeScript Source](examples/authentication-via-http-header.ts)

#### Dynamically setting headers
If you want to set headers after the GraphQLClient has been initialised, you can use the `setHeader()` or `setHeaders()` functions.

```js
import { setHeaders, setHeader GraphQLClient } from 'graphql-request'

const client = new GraphQLClient(endpoint)

// Set a single header
client.setHeader('authorization', 'Bearer MY_TOKEN')

// Override all existing headers
client.setHeaders({
authorization: 'Bearer MY_TOKEN'
anotherheader: 'header_value'
})
```

### Passing more options to fetch

```js
Expand Down

0 comments on commit 3f51dab

Please sign in to comment.