Skip to content

Instantly share code, notes, and snippets.

@AlfieriChou
Created February 10, 2018 03:22
Show Gist options
  • Save AlfieriChou/5440e34d3fc23d21dce8f74424e25080 to your computer and use it in GitHub Desktop.
Save AlfieriChou/5440e34d3fc23d21dce8f74424e25080 to your computer and use it in GitHub Desktop.
import request from 'request-promise';
const geo = (req, res) => {
const latitude = req.body.latitude;
const longitude = req.body.longitude;
let options = {
method: 'POST',
uri: 'https://apis.map.qq.com/ws/geocoder/v1',
body: {
some: 'payload'
},
json: {
key: "key",
location: latitude + "," + longitude
}
}
try{
request(options).then((parsedBody) => {
res.json({
success: 1,
result: parsedBody
});
});
} catch(err) {
return res.status(500).send({
message: '数据读取失败',
success: 0
});
}
}
export{
geo
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment