GET AllDeals

Hello everybody,

I have some doubts about how to access the objects from the array of objects returned from the endpoint, this is my code in JS,

When I run it it returns nothing,

If I remove the “[i].id” it returns all the data, but I wanted to access each one individually

var axios = require(“axios”);

var config = {
method: “get”,
maxBodyLength: Infinity,
url: https://${domain}.pipedrive.com/api/v1/deals?&limit=500&api_token=${pipeDriveAPI},
headers: {},
};

axios(config).then(function (response) {
const object = response.data;
for (let i = 0; i < object.length; i++) {
console.log(object[i].id)
}
});

Hi @Eduardo_Diniz
Welcome to the community ! :wave: and thanks for being patient :slight_smile: Here’s an example payload that showcases the response to getting all deals via Pipedrive API

https://www.postman.com/pipedrive-developers/workspace/pipedrive-api-collection/example/14918448-fd380957-b1a4-4329-a32c-d2285f8c6bda

Do you face any particular error? As long as you iterate on the data property (an array of deal objects), you should be able to access them individually. Perhaps try accessing object.data as response.data would provide the response JSON and there is a data property that you’d have to access (part of the successful response) to iterate on the individual objects?