Skip to content

Instantly share code, notes, and snippets.

@muneneevans
Created November 4, 2017 09:32
Show Gist options
  • Save muneneevans/644e7c1bc1bc51cc50e00a7d55c6466c to your computer and use it in GitHub Desktop.
Save muneneevans/644e7c1bc1bc51cc50e00a7d55c6466c to your computer and use it in GitHub Desktop.
class JsonPlaceHolderService{
static getPosts(){
const url = 'https://jsonplaceholder.typicode.com/posts'
//define my request
const request = {
method: "GET",
};
//make the call and return a json object of the response
return fetch(url, request)
.then(response => {
return response.json()
})
.catch(error => {
throw( error)
})
}
}
export default JsonPlaceHolderService
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment