gpt4 book ai didi

node.js - 如何解析来自 Slack 的交互消息?

转载 作者:太空宇宙 更新时间:2023-11-03 23:56:17 25 4
gpt4 key购买 nike

我想解析来自 Slack 的交互消息请求。这就是 Slack 在 their docs 中所说的:

The body of that request will contain a payload parameter. Your app should parse this payload parameter as JSON.

这看起来很简单,所以我像这样解析它:

JSON.parse(decodeURIComponent(body.split('=')[1]))

但是,在结果对象的字符串字段中,我看到加号而不是空格:

"There+should+not+be+pluses+here"

我在这里做错了什么?

最佳答案

查看了their library here ,事实证明,他们使用 Node 的 querystring.parse()

所以解析过程应该是这样的:

JSON.parse(querystring.parse(body).payload)

关于node.js - 如何解析来自 Slack 的交互消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56966163/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com