Hi @basdebruin ,
Thank you for showing interest, sorry for my late reply!
I got CORS error when running the subitem request through my root. I do not get this error when using other monday post or query features. Hence the Node.
I get no errors, only a broken promise error when I kill the Node.
When I send the requests manually, without using a loop I get Node console.log response that I have received the request for the first 6 subitem request. Then the Node stops responding and I have to kill it to get another 6 request - rinse & repeat until the queue is empty.
Sending requests to another API using very similar code (GET instead of POST) works!
Here is my code.
ROOT:
//createdItemID is previously created Item Id that the subItem will be posted into
var info = createdItemID + ',*^GT^*,' + "PlaceholderText";
var requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
}
fetch(`/subitem/${info}`, requestOptions)
.then(console.log("Sent subitem request!"))
.catch(error => console.log('error', error));
}
And Node:
app.post("/subitem/:info", async (request, response) => {
console.log("Node has received a sub item request!");
const info = request.params.info.split(",*^GT^*,");
const itemId = parseInt(info[0]);
const itemName = String(info[1]);
console.log(itemId);
let query =
"mutation($itemId:Int, $itemName:String){ create_subitem (parent_item_id: $itemId, item_name: $itemName){ id board { id }}}";
fetch("https://api.monday.com/v2", {
method: "post",
headers: {
"Content-Type": "application/json",
Authorization:
********************,
},
body: JSON.stringify({
variables: { itemId, itemName },
query: query,
}),
})
.then((res) => res.json())
.then((res) => console.log(JSON.stringify(res, null, 2)))
.catch((error) => console.log("error", error));
});
Thanks in advance!