Skip to main content

So I  tried to get data from API and received this kind of error:

Cannot read properties of undefined (reading 'map') What happened (You are seeing this because you are an admin): Starting GET request to XXXYYYYXXXXYYYYXXXXYYY Received 200 code from XXXYYYXXXXYYYYXXXYYYXXXXYY after 419ms Received content "{"_embedded":{"clients"::{"clientId":”123123123123123","version":25,"firstName":"XXX","" Cannot read properties of undefined (reading 'map')

What should be changed in code to see proper response?

 

 

this is how response looklike in postman:

{

"_embedded": {

"clients": t

{

"clientId": “123123123123123",

"version": 25,

"firstName": "XXX",

"lastName": "`yyy",

"mobile": "123456789",

"landLine": "",

"email": "aaaaaaaa@gmail.com",

"createdAt": "2018-09-06T09:08:14.000Z",

"updatedAt": "1999-01-09T04:01:30.000Z",

"address": {

"streetAddress1": "",

"streetAddress2": "",

"city": "",

"state": "",

"postalCode": "",

"country": ""

},

"birthDate": "1988-01-01",

"clientSince": "2011-09-06T09:08:14.000Z",

"gender": "MALE",

"notes": "",

"smsMarketingConsent": false,

"emailMarketingConsent": false,

"smsReminderConsent": true,

"emailReminderConsent": true,

"preferredStaffId": "XYZ",

"creditAccount": {

"creditDays": 0,

"creditLimit": 0.00

},

"loyaltyCard": {

"serial": "",

"points": 0

},

"creatingBranchId": "XXXXXXXXXXXXX",

"archived": false,

"deleted": false,

"banned": false,

"clientCategoryIds": y

"XXXXXXXX",

"XXXXXXXXXX"

],

"firstVisit": "1999-01-01"

},

 

 

Code for API endpoint:

const options = {
  url: `THIS IS MY API LINK`,
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'X-BUSINESS-ID': bundle.authData.business_id
  },
  params: {
    
  },
};

return z.request(options).then((response) => {
  response.throwForStatus();
  const results = response.json;

  const clients_list = resultss"clients"].map((item) => {
    return Object.assign(item, {
      id: itemi"clientId"],
    });
  });

  return clients_list;
});

Hi @MicCreaks, welcome to the Community! 🙂

To help us get a bit more context on the situation here can you tell us where you’re running into that error exactly?

For example, is it in a Code by Zapier or Webhooks by Zapier action in a Zap? Or are you encountering that error when developing an integration on the Zapier Platform?

Also what app’s API are you attempting to make a GET request to? If you can share a link to the app’s API docs that would be much appreciated.

Looking forward to hearing from you!


I working on new integration on zapier platform and this error occurred when I tried to create a trigger. This is a link to app API documentation https://support.phorest.com/hc/en-us/articles/360018509380-Phorest-API-Common-Use-Cases

I would like to get clients from clients API to moved them in to zoho crm.

http://developer.phorest.com/#!/Client/getClients

 

M.


Hi @MicCreaks, welcome to the Community! 🙂

To help us get a bit more context on the situation here can you tell us where you’re running into that error exactly?

For example, is it in a Code by Zapier or Webhooks by Zapier action in a Zap? Or are you encountering that error when developing an integration on the Zapier Platform?

Also what app’s API are you attempting to make a GET request to? If you can share a link to the app’s API docs that would be much appreciated.

Looking forward to hearing from you!

Hi,

Im working on new integration on zapier platform and this error occurred when I tried to create a trigger. This is a link to app API documentation https://support.phorest.com/hc/en-us/articles/360018509380-Phorest-API-Common-Use-Cases

I would like to get clients from clients API to moved them in to zoho crm.

http://developer.phorest.com/#!/Client/getClients

 

M.


Reply