Last active
January 19, 2018 14:18
-
-
Save nomanHasan/5228a180ad9da2156ca4f4e92f7972dd to your computer and use it in GitHub Desktop.
HttpClient #1
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
| import axios from 'axios' | |
| //Create a Http Client using Axios. Further modifications in this layer can be done later like Authorization. | |
| const post = (url = '', data = '', config = {}) => { | |
| return axios.post(url, data, config) | |
| } | |
| const get = (url) => { | |
| return axios(url) | |
| } | |
| const put = (url = '', data = '', config = {}) => { | |
| return axios.put(url, data, config) | |
| } | |
| //Cannot contain a delete method - Cause delete is a keyword. | |
| const del = (url = '', config = {}) => { | |
| return axios.delete(url, config) | |
| } | |
| //Encapsulating in a JSON object | |
| const HttpClient = { | |
| post, | |
| get, | |
| put, | |
| delete: del | |
| } | |
| export {HttpClient} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment