How can we set up a variable condition based on the input data?

Hello

I have a Google sheet with a list of URL e.g.
AAA .com
BBB .com
CCC .com and so on

At the HTTP request node, there is a JavaScript code parameter. Each domain runs different JavaScript. Can we create a condition to check the array data from the Google Sheet node to set up a lookup like this?

if input contain ‘AAA’ then output “document.querySelector(‘.AAA-content’).style.display=‘none’”
if input contain ‘BBB’ then output “document.querySelector(‘.BBB-content’).style.display=‘none’”
if input contain ‘CCC’ then output “document.querySelector(‘.CCC-content’).style.display=‘none’”

So I can use an expression for the HTTP Request node to apply the correct JS for each domain API call.

I thought the Switch Node was to achieve this use case, but does not seem to be…

Thanks

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

hello @Blueli

it depends on how are you going to map selectors. Generaly, you can manually map them:

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.