Set a variable

Hi everybody
In my case:

  • I get a price of something from source 1 by Webhook
  • I set it to myPrice variable by “set” node.
  • Because of specific reason I should get that price from another source (source 2). (for example source 1 is unreachable)
  • So I set second price in myPrice by another “set” node.

Can anyone help me how can I use myPrice variable that updated by source 1 or source 2 in new node?

I am very sorry but I sadly do not understand what you mean. Can you please try to describe it differently. Thanks!

I get Bitcoin price from source 1 (http request node 1)
Set node 1: myPrice = source 1 Bitcoin price
If node1: If source 1 is available: (true)
Google sheet node 1: add it to my google sheet table by append.
If node 1: If source 1 is unavailable: (false)
Http request 2: get Bitcoin price from source 2
Set node 2: myPrice = source 2 Bitcoin price
Google sheet node 1: add it to my google sheet table by append.

In google sheet node, how can I get myPrice variable without attention to its node?

I hope I could explain my situation:sleepy:

I think I understand it now. That should be possible with a simple IF-Node like that. As if it is false the False-Output will not contain any data:

To emulate the behavior that the first request does not return any data simply remove the “price” from the “Fake Request 1” node.

{
  "nodes": [
    {
      "parameters": {
        "values": {
          "number": [
            {
              "name": "price",
              "value": 1
            }
          ]
        }
      },
      "name": "Fake Request 1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "number": [
            {
              "name": "price",
              "value": 2
            }
          ]
        }
      },
      "name": "Fake Request 2",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        800,
        500
      ]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{!!$node[\"Fake Request 1\"].data[\"price\"]}}",
              "value2": true
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {},
      "name": "Fake Google Sheet",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1000,
        300
      ]
    }
  ],
  "connections": {
    "Fake Request 1": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fake Request 2": {
      "main": [
        [
          {
            "node": "Fake Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "Fake Google Sheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fake Request 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
1 Like