HTTPRequest in javascript welp :(

HTTPRequest in javascript welp :(

in API Development

Posted by: Nekres.1038

Nekres.1038

I am still learning and I would like to make a HTTP Request via javascript for the pvp stats of gw2. I have already worked with httprequest, but it was a snipped from another person (with permission of course) and it was so messy that I could use it, but I didn’t fully understand how the request works. It would be great if someone could show me a quick CLEAN snippet of a GET request for GW2 API pvp stats.

HTTPRequest in javascript welp :(

in API Development

Posted by: Nekres.1038

Nekres.1038

if possible without node.js

HTTPRequest in javascript welp :(

in API Development

Posted by: Lawton Campbell

Lawton Campbell

Web Programmer

Here’s an example for you. Should run fine in a browser — for node.js you’ll need to use a different method for fetching data.

HTTPRequest in javascript welp :(

in API Development

Posted by: darthmaim.6017

darthmaim.6017

Here is a simple example (no libraries required, but you need an up-to-date browser): https://jsbin.com/kozapureba/edit?js,console

HTTPRequest in javascript welp :(

in API Development

Posted by: Sondergaard.8469

Sondergaard.8469

You might also look into using a combination of Knockout and JQuery. It makes receiving and using the data received a lot easier.

Naturally you can do this without either, but using them makes life a whole heck of a lot easier in the long run and requires a lot less code. I also recommend them because the documentation is pretty awesome for both, and there are tons of tutorials available which makes learning how to use them even easier.

knockout

jquery <- this specifically links to the documentation on ajax requests.

Note, in the success property you can put a function that will execute once the request is complete. Inside that function you can catch the data coming back from the server and bind it to your knockout view model.

Knockout isn’t really necessary if your data is static and there aren’t any dynamic values, but I still like using it over other options.

(edited by Sondergaard.8469)

HTTPRequest in javascript welp :(

in API Development

Posted by: Nekres.1038

Nekres.1038

Why are you guys bumping this old thread? It was already gone to the bottom

I already have all learned the stuff I need. But thanks if you wanted to help.

Check out this reddit thread about what I have done with it:
https://www.reddit.com/r/Guildwars2/comments/4baeuv/hey_are_you_a_gw2_streamer/