经过多次尝试,我无法在内联编辑器中执行HTTP请求
const axios = require('axios');
function distance(agent){
const city1 = agent.parameters['geo-city'];
const city2 = agent.parameters['geo-city1'];
var response = "";
axios.post('https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins='+ city1 +'&destinations='+ city2 +'&key=KEY', {})
.then(res => {
const json = JSON.parse(res);
response = json.rows[0].elements[0].distance.text;
})
.catch(error => {
});
agent.add(response);
}
这不返回任何响应为什么?