0
我得从SWIFT内的HTTP请求到Google云功能/ Node.js的使用alamofire:为什么我用Alamofire传递给服务器的参数未定义?
Alamofire.request(url, method: .post, parameters: [
"api_version": apiVersion,
])
我知道这个请求被击中的服务器和服务器上执行的功能,因为我打印出日志消息,我在功能。
我也知道客户端上的apiVersion包含的数据是条纹api版本。
但是在此功能的服务器上:
exports.ephemeral_keys = functions.https.onRequest((req, res) => {
console.log("activated ephemeral keys") // prints to the console
const stripe_version = req.query.api_version //is undefined
的console.log(stripe_version)是伐木不确定。
任何想法?
******更新*********
我看了看这篇文章,我怀疑有一个编码问题,但建议是甜的。
How to add Alamofire URL parameters
感谢。
如果我看到正确的,你正在POST正文中发送参数,但你期待查询参数。 – jonaszmclaren
因此,请尝试将编码参数添加到您提供的链接中提到的Alamofire的'request'函数。 – jonaszmclaren
我找到了将节点上的服务器上的req.query.api_version行更改为req.body.api_version的答案。 Thx虽然。 – Mike