Created
April 3, 2019 05:26
-
-
Save dharavp/8abbafbc39a1eac1cb19236cd516b0e1 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
import axios from 'axios'; | |
export const getApi = (url) => { | |
return new Promise((resolve, reject) => { | |
axios.defaults.headers.common.Authorization = ''; | |
axios.get(url) | |
.then((response) => { | |
resolve(response) | |
}) | |
.catch((error) => { | |
reject(error) | |
}); | |
}) | |
}; | |
export const postApi = (url, AuthToken, formData) => { | |
return new Promise((resolve, reject) => { | |
axios.defaults.headers.common.Authorization = AuthToken; | |
axios.post(url, formData) | |
.then((response) => { | |
if (response.data !== null) { | |
const statusCode = response.data.status_code; | |
if (statusCode === 200) { | |
resolve(response) | |
} | |
} | |
}) | |
.catch((error) => { | |
reject(error) | |
}); | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment