Trying to use create a meeting api with javascript

HI, I was tasked with making an HTML and javascript page so that people could just type in some information and then just be given a link to their scheduled meeting.

I am using JWT as it seemed to be easier for the two to use.

I know fetch() is throwing me an error. that error being TypeError: NetworkError when attempting to fetch resource. but at this point, I am just wondering if I am calling it correctly.

I would use a screenshot of the code, but I can’t upload pictures. so I am just going to copy-paste it here. I have removed my methods of creating the JWT token for safety reasons

var date

var time

var topics

var Password

var Dura

var josnbody

var combine

var url

var email

var sJWT

document.getElementById(“myBtn”).onclick = function () { GrabV };

document.getElementById(“myBtn”).addEventListener(“click”, GrabV)

function GrabV() {

email = document.getElementById(“email”).value

date = document.getElementById(“date”).value

time = document.getElementById(“time”).value

topics = document.getElementById(“topic”).value

Password = document.getElementById(“Password”).value

Dura = document.getElementById(“duration”).value

Dura = parseInt(Dura)

combine = date + “T” + time

MakeToken()

}

function MakeToken() {

MakeJson()

}

function MakeJson() {

jsonbody = {

"topic": topics,

"type": 2,

"start_time": combine,

"duration": Dura,

"password": Password,

"timezone": 'America/New_York',

"settings": {

  "host_video": true,

  "participant_video": true,

  "join_before_host": false,

  "mute_upon_entry": true,

}

}

Func()

}

function Func() {

url = ‘https://api.zoom.us/v2/users/’ + email + ‘/meetings’

var jboy = JSON.stringify(josnbody)

var head = new Headers();

head.append(‘Content-Type’, ‘application/json’);

head.append(‘authorization’, ‘Bearer’ + sJWT);

var initObject = {

method: 'POST', headers: head, body: jboy

}

var input = new Request(url, initObject)

fetch(input)

.then(function (repsonse) {

  return response.json();

})

.then(function (data) {

  console.log(data);

})

.catch(function (err) {

  console.log("Something went wrong!", err);

});

}

Hey @brandonh,

Thank you for reaching out to the Zoom Developer Forum. When you the TypeError is there an HTTP status returned from the API or is your application unable to contact the endpoint at all?

Have you tried making that same request from a REST client like Postman? What are the results?

Thanks,
Max

The TypeError is TypeError: NetworkError when attempting to fetch resources. I believe this means that it is not even getting a return from the API and just cannot contact it. For Postman I am very much new to it. Before writing the code I did mess with making a meeting using O2Auth on Postman. I got that to work. I did not try to do JWT with Postman as I am new to it and O2Auth seems easier with Postman, But harder to do with code.

Hey @brandonh,

Thank you for following up on this. I would make sure there isn’t a firewall, VPN or other network configuration on the device you’re testing with. You can also try making the request on a different network and device to rule out either as a factor.

Thanks,
Max

I will check my network setting and try other devices to see if that works. Not sure if you know but is my code good or should I try to rewrite it. Kind of my first time trying something like that.

Hey @brandonh,

I’ll note that you’ll want to make sure that you are making these API calls from the back-end of your app. Calling them from client-side javascript will result in a CORS error which could be the cause of what you’re seeing here.

In other words, it might be best to test this out on a REST client like Postman and then try making the calls from Node and Express.

Let me know if that helps.

Thanks,
Max