Created
August 25, 2017 05:08
-
-
Save rosd89/0e94cab2a65b24f4fb53dce86fb37dc1 to your computer and use it in GitHub Desktop.
This file contains 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
const axios = require('axios'); | |
const querystring = require('querystring'); | |
const headers = {'Content-Type': 'application/x-www-form-urlencoded'}; | |
/** | |
* ajax http get request | |
* | |
* @param url | |
* @param params | |
*/ | |
exports.get = (url, params) => axios.get(url, {params}); | |
/** | |
* ajax http post request | |
* | |
* @param url | |
* @param params | |
*/ | |
exports.post = (url, params) => axios.post(url, querystring.stringify(params), {headers}); | |
/** | |
* ajax http put request | |
* | |
* @param url | |
* @param params | |
*/ | |
exports.put = (url, params) => axios.put(url, querystring.stringify(params), {headers}); | |
/** | |
* ajax http patch request | |
* | |
* @param url | |
* @param params | |
*/ | |
exports.patch = (url, params) => axios.patch(url, querystring.stringify(params), {headers}); | |
/** | |
* ajax http delete request | |
* | |
* @param url | |
* @param params | |
*/ | |
exports.delete = (url, params) => axios.delete(url, {params}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment