Created
July 24, 2018 09:44
-
-
Save mokxter/f2b4afecf22cebd89691fad6b3bd8c8c to your computer and use it in GitHub Desktop.
Axios Request Sample
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
| const axios = require('axios'); | |
| const url = 'http://localhost/oauth/token'; | |
| const getToken = async url => { | |
| try { | |
| const body = { | |
| grant_type: 'password', | |
| client_id: '', | |
| client_secret: '', | |
| username: '', | |
| password: '' | |
| }; | |
| const response = await axios.post(url, body); | |
| const data = response.data; | |
| const { response: result } = data; | |
| console.log(data); | |
| console.log({ result }); | |
| } catch (error) { | |
| console.log(error.response.data); | |
| } | |
| }; | |
| getToken(url); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment