# Using JWT with nodejs fetch

**URL:** <https://devforum.zoom.us/t/using-jwt-with-nodejs-fetch/32893>\
**Category:** API and Webhooks\
**Created:** [October 12, 2020, 12:23am UTC](https://devforum.zoom.us/t/using-jwt-with-nodejs-fetch/32893 "2020-10-12T00:23:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mobitinker](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/mobitinker/32/15184_2.png) [@mobitinker](https://devforum.zoom.us/u/mobitinker)\
**Post date:** [October 12, 2020, 12:23am UTC](https://devforum.zoom.us/t/using-jwt-with-nodejs-fetch/32893/1 "2020-10-12T00:23:05Z")

</div>

I have a simple app that can successfully use the API with a JWT token. When I try to use nodejs fetch I have problems. I get a 403 error. The code is below. I must be setting up my headers incorrectly. The token value has been working, just not with fetch. I’m running on localhost:3000. The error returned in the catch is "TypeError: Failed to fetch {stack: ‘TypeError: Failed to fetch’, message: ‘Failed to fetch’}  
"

async function meetingsGet(email, startDate, endDate) {

var url = `https://api.zoom.us/v2/users/${email}/meetings?type=past&page_size=300`;  
var bearer = 'Bearer ’ + token;  
email = encodeURIComponent(encodeURIComponent(email))  
fetch(url, {  
method: ‘GET’,  
headers: {  
‘Authorization’: bearer,  
‘User-Agent’: ‘Zoom-api-Jwt-Request’,  
‘Content-Type’: ‘application/json’  
}  
}).then(responseJson =\> {  
var items = JSON.parse(responseJson.\_bodyInit);  
console.log(“fetched”, responseJson);  
})  
.catch(error =\> console.log(error));  
}

---

<div class="post-metadata">

**Author:** ![alexmayo](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/alexmayo/32/27289_2.png) [@alexmayo](https://devforum.zoom.us/u/alexmayo)\
**Post date:** [October 12, 2020, 12:51am UTC](https://devforum.zoom.us/t/using-jwt-with-nodejs-fetch/32893/2 "2020-10-12T00:51:28Z")

</div>

Just curious, have you tried removing the **user-agent** and **content-type** headers, since they are not required?

Other than that, I don’t see any reason as to why the code would not be working. Could you post an example of a completed request object? Have you tried this on a production server, rather than localhost?

Thanks,  
Alex

---

<div class="post-metadata">

**Author:** ![mobitinker](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/mobitinker/32/15184_2.png) [@mobitinker](https://devforum.zoom.us/u/mobitinker)\
**Post date:** [October 12, 2020, 6:31pm UTC](https://devforum.zoom.us/t/using-jwt-with-nodejs-fetch/32893/3 "2020-10-12T18:31:52Z")

</div>

Thanks for taking a look. Here is the debug output for the request in Chrome. I checked the jwt token and it looks correct.

Request URL:

[https://api.zoom.us/v2/users/rachel.gossett%40sultan.k12.wa.us/meetings?type=past&page\_size=300](https://api.zoom.us/v2/users/rachel.gossett%2540sultan.k12.wa.us/meetings?type=past&page_size=300)

Referrer Policy: no-referrer-when-downgrade

Request Headers

accept:application/json  
authorization: Bearer   
content-type: application/json  
Referer: [http://localhost:3000/reports/gbezoomsummary](http://localhost:3000/reports/gbezoomsummary)  
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10\_15\_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36

I need to create a production server yet. I’m hoping it’s possible to debug using localhost in some way.

---

<div class="post-metadata">

**Author:** ![mobitinker](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/mobitinker/32/15184_2.png) [@mobitinker](https://devforum.zoom.us/u/mobitinker)\
**Post date:** [October 12, 2020, 8:05pm UTC](https://devforum.zoom.us/t/using-jwt-with-nodejs-fetch/32893/4 "2020-10-12T20:05:10Z")

</div>

Major brain fart. Since I had api calls working on a node server with a JWT I assumed I could do the same from within a React application. I need to look at the Web SDK. Too long out of the programming saddle!!

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [October 12, 2020, 8:50pm UTC](https://devforum.zoom.us/t/using-jwt-with-nodejs-fetch/32893/5 "2020-10-12T20:50:10Z")

</div>

I’m glad @alexmayo could help, @mobitinker! 🙂

Best,  
Will

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [November 12, 2020, 6:50am UTC](https://devforum.zoom.us/t/using-jwt-with-nodejs-fetch/32893/6 "2020-11-12T06:50:12Z")

</div>

Closed on November 12, 2020, 6:50am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
