Pipedrive API javascript error

This is my code to get data:
.get( "https://api.pipedrive.com/v1/deals?start=0&limit=500&filter_id=43&api_token=TOKEN", function( data ) { var persons = []; persons = []; .each( data.data, function( key, value ) {

And this is the code to get all names of my clients:
var names = value.person_id.name;

And that gives me an error like this:
Uncaught TypeError: Cannot read property ‘name’ of null

It used to work and now it suddenly fails.

Hi @Z500Eesti first thing I would check is if maybe those deals that this filter is returning maybe have no person linked to them?

1 Like

Ok, that may be the case if my sales team created a deal without a linked person.

I can console log var names = value[“person_id”] and then I get the arrays shown.

Can you suggest me a way to filter out only the deals that have a person linked to it?

I just added a filter in Pipedrive to show only deals with a contact and that fixed the issue. Maybe there is a better solution, but I consider it solved for now.

Glad it helped, seems like a good solution but that would depend on what you need exactly. Let us know if you need any further help ahead.