Created
November 4, 2017 09:32
-
-
Save muneneevans/644e7c1bc1bc51cc50e00a7d55c6466c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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