它与Angular 2完全相同- 检查图像URL是有效还是坏了.
我怎样才能在vuejs中实现这个?
我正在尝试发送两个json但它不起作用.它打印TypeError: res.json is not a function但我不明白为什么会发生.有什么想法吗?谢谢 !!
app.post('/danger', function response(req, res) {
let placeId = req.body.data;
let option = {
uri: 'https://maps.googleapis.com/maps/api/directions/json?',
qs: {
origin:`place_id:${placeId[0]}`, destination: `place_id:${placeId[1]}`,
language: 'en', mode: 'walking', alternatives: true, key: APIKey
}
};
rp(option)
.then(function(res) {
let dangerRate = dangerTest(JSON.parse(res), riskGrid);
res.json({ data: [res, dangerRate]});
})
.catch(function(err) {
console.error("Failed to get JSON from Google API", err);
})
});
Run Code Online (Sandbox Code Playgroud)