axios: added Basic Authentication Header for axios.js HTTP GET request
This commit is contained in:
parent
c7b97bb519
commit
8735357542
|
@ -6,11 +6,24 @@ function axiosGet () {
|
|||
console.log('axiosGet() started...');
|
||||
|
||||
//send HTTP GET via axios
|
||||
axios.defaults.baseURL = 'https://test-tarifmatrix.vbn.de:4245';
|
||||
const Usr = 'tbd';
|
||||
const Key = 'tbd';
|
||||
|
||||
//axios.defaults.baseURL = 'https://test-tarifmatrix.vbn.de:4245';
|
||||
axios.defaults.baseURL = 'https://tarifmatrix.vbn.de:4445';
|
||||
axios.defaults.headers.get['Content-Type'] = 'application/json;charset=utf-8';
|
||||
axios.defaults.headers.get['Access-Control-Allow-Origin'] = '*';
|
||||
|
||||
axios
|
||||
.get('fares/areas/info')
|
||||
.get('fares/areas/info', {
|
||||
// Axios looks for the `auth` option, and, if it is set, formats a
|
||||
// basic auth header for you automatically.
|
||||
auth: {
|
||||
username: `${Usr}`,
|
||||
password: `${Key}`
|
||||
}
|
||||
})
|
||||
//handle rsp in async manner
|
||||
.then((response) => {
|
||||
if (response.data) {
|
||||
console.log('axiosGet() response.data: ', response.data);
|
||||
|
|
Loading…
Reference in New Issue