我正在尝试重新创建这个创建一个新的卡片API,但是根据文档,我不确定我应该如何传递所需的数据,它是否应该在查询参数(req.params 来收集数据)中,例如/1/cards?name=cardName&desc=cardDescription
,还是应该在 req.body 里面?
该文档显示了该 API 的大量示例。其中一个示例甚至是为 nodejs 编写的。很明显,这些选项是查询参数,请求本身没有正文数据。
// This code sample uses the 'node-fetch' library:
// https://www.npmjs.com/package/node-fetch
const fetch = require('node-fetch');
fetch('https://api.trello.com/1/cards?idList=5abbe4b7ddc1b351ef961414', {
method: 'POST',
headers: {
'Accept': 'application/json'
}
})
.then(response => {
console.log(
`Response: ${response.status} ${response.statusText}`
);
return response.text();
})
.then(text => console.log(text))
.catch(err => console.error(err));
同样,CURL 示例也清楚地说明了这一点:
curl --request POST \
--url 'https://api.trello.com/1/cards?idList=5abbe4b7ddc1b351ef961414' \
--header 'Accept: application/json'
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句