I’m having trouble with my Zapier integration. When I perform a search through my API with a specific item’s ID, it returns a single object. However, Zapier shows an error indicating that it requires the results to be formatted as an array instead.
My API response looks like this:
{
"found": true,
"product": {
"dateCreated": "2019-05-23T10:11:18.514Z",
"category": "Sample",
"active": 1,
"productId": "789abc123def456ghi789jkl012",
"name": "Sample Product"
}
}
When I conduct the Zap test, I encounter the following error:
Results must be an array, got: object
Here’s my implementation:
module.exports = {
key: 'product',
noun: 'productlookup',
display: {
label: 'Search for product',
description: 'verify if product exists'
},
operation: {
inputFields: [
{
key: 'prodId',
type: 'string',
label: 'Product ID',
helpText: 'Example: abc123def456ghi789'
}
],
perform: (z, bundle) => {
const endpoint = 'http://SERVER:8081/api/productlookup/';
const requestOptions = {
params: {
productId: bundle.inputData.prodId
}
};
return z.request(endpoint, requestOptions)
.then(response => JSON.parse(response.content));
},
sample: {
"found": true,
"product": {
"dateCreated": "2019-05-23T10:11:18.514Z",
"category": "Sample",
"active": 1,
"productId": "789abc123def456ghi789jkl012",
"name": "Sample Product"
}
}
}
};
What can I do to modify this output so that Zapier will accept the response format?