问题描述
https://api.hubapi.com/crm-objects/v1/objects/line_items/batch-read?hapikey=demo&properties=name&properties=quantity&properties=price
POST BODY 示例:
{
"ids": [
9845651,9867373
]
}
节点语法
var request = require("request-promise");
const { ids } = req.body;
console.log("ids::",ids);
const result = await request({
method: "POST",url: `https://api.hubapi.com/crm-objects/v1/objects/line_items/batch-read`,qs: {
hapikey: "demo",properties="name"
},body: {
ids,},json: true,});
问题是,无法设置qs显示属性,我需要收集名称、数量、价格属性信息,如何在节点语法上设置它们?我的以下语法不起作用
properties=["name","quantity","price"]
解决方法
您可以这样做而不是properties=["name","quantity","price"]
const properties = ['name','quantity','price']
const qs = ['hapikey=demo&']
properties.forEach((key) => {
qs.push('properties=' + key + '&')
})
console.log(qs.join(''))
//this gives: hapikey=demo&properties=name&properties=quantity&properties=price&
以后
const result = await request({
method: 'POST',url: `https://api.hubapi.com/crm-objects/v1/objects/line_items/batch-read`,qs: `${qs.join('')}`,body: { ids },json: true,})
所以它会给查询字符串 hapikey=demo&properties=name&properties=quantity&properties=price