【发布时间】:2021-04-19 20:29:56
【问题描述】:
我有一个小型节点服务器,我使用框架 fastify。
在我的一条路线中,我想从第三方 API 获取数据。
我尝试了以下sn-p:
fastify.route({
method: 'GET',
url: 'https://demo.api.com/api/v2/project/',
handler: async function ({ params, body}, reply) {
if (!body) return reply.send({ sucess: false })
console.log('testing')
console.log(body)
return reply.send({ sucess: true })
}
})
很遗憾,我无法通过 get 调用 URL,因为 GET url 只能以 '/' 开头。
如何通过 fastify 调用第三方 api?我需要延期吗?
【问题讨论】: