Question

Array Error and ID Error Won't Go Away

  • 6 May 2023
  • 1 reply
  • 14 views

Userlevel 1

Hi all,

 

I'm attempting to handle a response from my company's api that I'm getting through Zapier. Our api returns {"status":"SUCCESS","description":"","result": etc. etc.

I'm getting 2 error messages

1. Results must be an array

2. Got a result missing the "id" property

 

I have tried this as a solution based on other conversations I saw on here.

 

return z.request(options)

  .then((response) => {

    //response.throwForStatus();

    // You can do any parsing you need for results here before returning them

    const myJson = response.json;

    const justResults = myJson.result;

    const results = [justResults];

    //results.throwForStatus();

    return results;

  });

 

I would expect this to work because results contains an id field, and I'm returning an array. I'm still getting those error messages even though I've refreshed my logs. Does anyone know what's causing this? I'm still getting:

 

- Results must be an array, got: object, ({"status":"SUCCESS","description":"","result":{"la) 

- Got a result missing the "id" property ("SUCCESS")

 

Thanks,


1 reply

Userlevel 1

For some reason this seems to have worked for me:

 

return z.request(options)
  .then((response) => {
    //response.throwForStatus();
    // You can do any parsing you need for results here before returning them
    z.console.log('response');
    z.console.log(response);
   return [response.json.result]
  });

Reply