Unable to get all deals

Hi,

I have done this:

import Pipedrive from 'pipedrive';

const pipedriveNextID = () => {
    const apiClient = new Pipedrive.ApiClient();
    const api_key = apiClient.authentications['api_key'];
    api_key.apiKey = 'XXXXXXXXXXXXXXXX';
    const apiInstance = new Pipedrive.DealsApi(apiClient);
    const opts = {
        start: 0, // Number | Pagination start
        limit: 100, // Number | Items shown per page
    };
    apiInstance.getDeals(opts).then(
        (data: string) => {
            console.log('API called successfully. Returned data: ' + data);
        },
        (error: unknown) => {
            console.error(error);
        },
    );
};

but i just get an error message:

Cannot read properties of undefined (reading ‘ApiClient’)

What am i doing wrong?

Thanks for the help!

Hey @Erik

Welcome to the community :wave:

Can you share the complete snippet with the Node.js and Pipedrive SDK version? I did some tiny modifications and was able to invoke the API.

import Pipedrive from 'pipedrive';

const pipedriveNextID = async () => {
    const apiClient = new Pipedrive.ApiClient();
    const api_key = apiClient.authentications['api_key'];
    api_key.apiKey = 'xxx';
    const apiInstance = new Pipedrive.DealsApi(apiClient);
    const opts = {
        start: 0, // Number | Pagination start
        limit: 100, // Number | Items shown per page
    };
    await apiInstance.getDeals(opts).then(
        (data) => {
            console.log('API called successfully. Returned data: ');
            console.log(data);
        },
        (error) => {
            console.error(error);
        },
    );
};

pipedriveNextID();