Skip to content

Instantly share code, notes, and snippets.

@mokxter
Created July 24, 2018 09:44
Show Gist options
  • Save mokxter/f2b4afecf22cebd89691fad6b3bd8c8c to your computer and use it in GitHub Desktop.
Save mokxter/f2b4afecf22cebd89691fad6b3bd8c8c to your computer and use it in GitHub Desktop.
Axios Request Sample
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