feat(axios): add function axiosGetVehiclePosition

This commit is contained in:
dancingCycle 2022-09-08 13:55:14 +02:00
parent c9df2b7134
commit 8b234c6be9
1 changed files with 27 additions and 2 deletions

View File

@ -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>
);
}