Example code:
const SiteClient = require('datocms-client').SiteClient;
const client = new SiteClient('YOUR-API-TOKEN');
client.webhookCalls.all()
.then((webhookCalls) => {
webhookCalls.forEach((webhookCall) => {
console.log(webhookCall);
});
})
.catch((error) => {
console.error(error);
});
Returned output:
> node example.js
{
"id": "42",
"entityType": "item",
"eventType": "update",
"createdAt": "2016-09-20T18:50:24.914Z",
"requestUrl": "https://www.example.com/webhook",
"requestHeaders": {
"accept": "*/*",
"userAgent": "DatoCMS (datocms.com)",
"authorization": "Basic Y2lhbzptaWFv",
"contentType": "application/json"
},
"requestPayload": "{ \"entity_type\": \"item\", \"event_type\": \"update\", \"entity\": { \"id\": \"293467\", \"type\": \"item\", \"attributes\": { \"created_at\": \"2018-05-22T10:13:00.461Z\", \"updated_at\": \"2018-07-30T14:13:50.068Z\", \"is_valid\": true, \"avatar\": { \"path\": \"/205/1526984443-untitled-drawing.png\", \"format\": \"png\", \"size\": 242630, \"alt\": null, \"title\": null, \"width\": 329, \"height\": 286 }, \"name\": \"3Francesco Falchy\", \"gallery\": [] }, \"relationships\": { \"item_type\": { \"data\": { \"id\": \"1423\", \"type\": \"item_type\" } }, \"published_version\": { \"data\": { \"id\": \"670532\", \"type\": \"item_version\" } }, \"current_version\": { \"data\": { \"id\": \"670532\", \"type\": \"item_version\" } } } } }",
"responseStatus": 200,
"responseHeaders": {
"via": "1.1 vegur, 1.1 37c0945d19329fccc23efb283d01aa06.cloudfront.net (CloudFront)",
"date": "Fri, 27 Jul 2018 11:59:20 GMT",
"server": "gunicorn/19.6.0"
},
"responsePayload": "ok",
"webhook": "312"
}