Created
February 10, 2018 03:22
-
-
Save AlfieriChou/5440e34d3fc23d21dce8f74424e25080 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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