# Dgraph-js-http setSlashApiKey breaks

**URL:** https://discuss.dgraph.io/t/dgraph-js-http-setslashapikey-breaks/11250
**Category:** Dgraph Cloud
**Tags:** dgraph
**Created:** [November 2, 2020, 1:40pm UTC](https://discuss.dgraph.io/t/dgraph-js-http-setslashapikey-breaks/11250 "2020-11-02T13:40:40Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Sydney-o9](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/sydney-o9/32/2378_2.png) [@Sydney-o9](https://discuss.dgraph.io/u/Sydney-o9)
#### Post date: [November 2, 2020, 1:40pm UTC](https://discuss.dgraph.io/t/dgraph-js-http-setslashapikey-breaks/11250/1 "2020-11-02T13:40:41Z")

</div>

Hi Team,

The client dgraph-js-http breaks when setting the Slash API key.

See [dgraph-js-http/clientStub.js at master · dgraph-io/dgraph-js-http · GitHub](https://github.com/dgraph-io/dgraph-js-http/blob/master/lib/clientStub.js#L274-L280)

`setSlashApiKey(apiKey)` is missing the following to create headers if undefined.

```auto
this.options.headers === undefined && (this.options.headers = {});

```

Hence, one would get a `TypeError: this.options.headers is undefined`

I have submitted a PR [Fix issue where setSlashApiKey would break if no headers was set. by Sydney-o9 · Pull Request #34 · dgraph-io/dgraph-js-http · GitHub](https://github.com/dgraph-io/dgraph-js-http/pull/34)

---

<div class="post-metadata">

### Author: ![gja](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/gja/32/2654_2.png) [@gja](https://discuss.dgraph.io/u/gja)
#### Post date: [November 2, 2020, 5:02pm UTC](https://discuss.dgraph.io/t/dgraph-js-http-setslashapikey-breaks/11250/4 "2020-11-02T17:02:33Z")

</div>

Thanks for the PR. I’ll get this merged and released shortly.
