feat(axios): add function axiosGetVehiclePosition
This commit is contained in:
parent
c9df2b7134
commit
8b234c6be9
|
@ -1,7 +1,7 @@
|
|||
import React from 'react';
|
||||
import './style/main.less';
|
||||
import axios from 'axios';
|
||||
|
||||
/*
|
||||
function axiosGet () {
|
||||
console.log('axiosGet() started...');
|
||||
|
||||
|
@ -36,6 +36,31 @@ function axiosGet () {
|
|||
});
|
||||
console.log('axiosGet() done.');
|
||||
}
|
||||
*/
|
||||
function axiosGetVehiclePosition () {
|
||||
console.log('axiosGetVehiclePosition() started...');
|
||||
|
||||
|
||||
//axios.defaults.baseURL = 'https://test-tarifmatrix.vbn.de:4245';
|
||||
//axios.defaults.baseURL = 'https://tarifmatrix.vbn.de:4445';
|
||||
axios.defaults.baseURL = 'https://data.vbn.de';
|
||||
axios.defaults.headers.get['Access-Control-Allow-Origin'] = '*';
|
||||
|
||||
axios
|
||||
.get('vehicle-position')
|
||||
//handle rsp in async manner
|
||||
.then((response) => {
|
||||
if (response.data) {
|
||||
console.log('axiosGetVehiclePosition() response.data: ', response.data);
|
||||
} else {
|
||||
console.log('axiosGetVehiclePosition() response.data unavailable ');
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
console.log('axiosGetVehiclePosition() done.');
|
||||
}
|
||||
|
||||
/*
|
||||
*component Main
|
||||
|
@ -47,7 +72,7 @@ class Main extends React.Component {
|
|||
return (
|
||||
<div>
|
||||
<p>main</p>
|
||||
<button onClick={axiosGet}>axios</button>
|
||||
<button onClick={axiosGetVehiclePosition}>axios</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue