Help needed to read binary file and use values in function node

Describe the issue/error/question

I need help to read a binary file data, and use the values inside a function node. so far I use the “Read Binary File” node, then “Move Binary to JSON”. so far I have the values. How can I reference them inside my function node? I know the following piece of code exists: const staticData = getWorkflowStaticData(‘node’); but I’m not a JS expert to know how to use it.

What is the error message (if any)?

Please share the workflow

Information on your n8n setup

  • n8n version: 0.170
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Adding the output of the “Move Binary to Json” node

[
  {
    "at": "xxxxxxxxxxxxxxx",
    "rt": "xxxxxxxxxxxxxxxxxx",
    "user": {
      "clientInfo": {
        "model": "xxxxx",
        "os": "xxxxx",
        "imei": "xxxxxxxxxxxx",
        "romVersion": "xxx",
        "appVersion": "xxxxxxxxxxx"
      },
      "_id": "xxxxxxxxxxxxx",
      "email": "xxxxxxxxxxxxx",
      "password": "xxxxxxxxxxx",
      "appId": "xxxxxxxxxxxx",
      "apikey": "xxxxxxxxxxxx",
      "createdAt": "xxxxxxxxxxxxxxxxxxx",
      "__v": 0,
      "lang": "en",
      "online": false,
      "onlineTime": "xxxxxxxxxxxxx",
      "appInfos": [
        {
          "os": "xxxx",
          "appVersion": "xxxxx"
        }
      ],
      "ip": "xxxxxxx",
      "location": "",
      "offlineTime": "xxxxxxxxxxx",
      "userStatus": "2",
      "countryCode": "xxx",
      "currentFamilyId": "xxxxxxxx",
      "bindInfos": {
        "gaction": [
          "xxxxxxx"
        ]
      },
      "extraPush": {
        "push": {
          "type": "xxx",
          "info": {
            "token": "xxxxxxxxxxxxxxx"
          }
        }
      },
      "language": "xx",
      "extra": {
        "ipCountry": "xx"
      }
    },
    "region": "xx"
  }
]

next the function node should execute the following code:

const ewelink = require('ewelink-api');
const newConnection = new ewelink({
    at: "value from binary file",
    region: "value from binary file"
});

const devices = await newConnection.getDevices();
return [
  {
    json: devices 
  }
]; 

Hey @ja3four,

Welcome to the community :tada:

You can use the following code snippet to refer the values:
for at: $json.at
for region: $json.region

I hope this helps :slight_smile: