我正在尝试重新创建这个create a new card接口,但是基于文档,我不确定我应该如何传递所需的数据,它应该在查询参数(req.params来收集数据)中,例如/1/cards?name=cardName&desc=cardDescription
,还是应该在req.body中?
发布于 2021-09-25 06:09:22
文档中显示了该API的大量示例。One of the examples甚至是为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'
https://stackoverflow.com/questions/69323533
复制相似问题