Skip to main content

How can I get this to return a yes or no if it exists?

 

const API_KEY = "X",
      boardId = X;

const sendRequest = async (payload) => {
  const response = await fetch("https://api.monday.com/v2/", {
    method: "POST",
    body: JSON.stringify(payload),
    headers: {
      "content-type": "application/json",
      authorization: API_KEY,
    },
  });

  const results = await response.json();

  return results;
};

const getItem = async () => {
  const query = `
      query {
        items_by_column_values (board_id: ${boardId}, column_id: "email_1", column_value: "${inputData.email}") {
          id
          name
        }
      }`;

  const response = await sendRequest({
    query,
  });

  const results = response.data,'items_by_column_values']s0].id;

  return results;
};


const response = await getItem();


output = {
   id: response
};

Hey there, @alexadagostino!

I can’t advise on how to do that using a Code step. But, it looks like you might be trying to run a search in monday.com to get certain column values, and check whether they were found or not, is that correct? 

If so, as an alternative you could use the Get Item by Column Value search action for monday.com to run the search, then you could add a Filter step or use Paths to check whether the _zap_search_was_found_status field is true or false (true indicates that it found something, false indicates that nothing was found). Would that work for your desired workflow here?