Tuesday, 30 May 2017

Testing REST api call without a package or ajax

Sorry if this is a duplicate, I couldn't find the correct information anywhere online because my search results were saturated with different packages I can use to do this.

I'm looking for a way to test my RESTful api calls, by making a get request within my javascript, but without using an npm package or jQuery/ajax (for internal reasons, yes - I'm aware there are packages that do this).

For context, I'm looking for something similar to the following request made with ajax:

getNewsStories(){
  $.ajax({
    url: '/api/newsstories/getnewsstories/',
    type: 'GET'
  })
  .done((data) => {
    console.log(data);
  })
  .fail((error) => {
    console.log(error);
  })
  return true;
}

If anyone has any insight on this that'd be massively appreciated, including any links for relevant info, because as mentioned I couldn't find anything myself.

Also - if this cannot be done, I'd be happy to know that too!

Thanks all,

Jock

Edit: spelling!



via jock.perkins

No comments:

Post a Comment