Skip to main content
Best answer

Add filter to response


Forum|alt.badge.img

I need to pull custom field data, but only if CustomField=true.

 

This is not working and I am sure it is a simple fix.

 

Line 20.

 

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

  const col = results["DatabaseColumns"].map((item) => {
    return {
      ...item,
      id: item["ColumnName"],
      if 'IsCustom': true,
    };
  });

Best answer by hank3rdBest answer by hank3rd

I was able to find a solution:

 

I was able to find a solution!

const options = {
  url: 'https://edapi.campaigner.com/v1/Database',
  method: 'GET',
  headers: {
    'X-API-KEY': bundle.authData.ApiKey
  },
  params: {
    'ApiKey': bundle.authData.ApiKey
  }
};

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

const col = results.DatabaseColumns.filter((item) => item.IsCustom).map((item) => {
    return {
      ...item,
      id: item["ColumnName"],
    };
  });

  return col});
View original
Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Danvers
Forum|alt.badge.img+12
  • Zapier Staff
  • 3731 replies
  • July 10, 2020

I’m sorry that we weren’t able to help you with this one @hank3rd 😞

 

I saw that you posted your question on Stack Overflow - if you do get a response there it would be fantastic if you could share it here in case someone has a similar question. Thanks!


Forum|alt.badge.img
  • Author
  • Beginner
  • 16 replies
  • Answer
  • July 16, 2020

I was able to find a solution:

 

I was able to find a solution!

const options = {
  url: 'https://edapi.campaigner.com/v1/Database',
  method: 'GET',
  headers: {
    'X-API-KEY': bundle.authData.ApiKey
  },
  params: {
    'ApiKey': bundle.authData.ApiKey
  }
};

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

const col = results.DatabaseColumns.filter((item) => item.IsCustom).map((item) => {
    return {
      ...item,
      id: item["ColumnName"],
    };
  });

  return col});