Upload File: Multipart-formdata

Hey @Kirst, sorry for the late response.

Ok the first example, the one with axios, will never get to the console.log as you are calling an async function without the await keyword. The function is returning before the HTTP request responds.

With regard to the second example, it will not work either because the request library do not return a promise and the keyword await as far as I know works when the function you are calling return a promise. To make work you have to either require request-promise and request or just use
request-promise-native.

I created two examples, one with axios and one with request-promise-native so that you can see it’s login to the console.

Hope that helps, let me know if you have any further questions.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "var request = require('request-promise-native')\n\nvar options = {\n  'method': 'GET',\n  'url': 'https://jsonplaceholder.typicode.com/todos/1',\n  'json': true,\n  'headers': {\n  }\n};\n\ntry {\n  const response = await request(options)\n    console.log(response);\n    return [{ json: response }] \n} catch (exception) {\n  throw new Error(exception);\n}\n\n\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        530,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const axios = require('axios');\n\ntry {\n    const response = await axios.get('https://jsonplaceholder.typicode.com/todos/1')\n    console.log(response.data);\n    return [{ json:response.data }] \n  } catch (error) {\n    console.log(error.response.body);\n    return [{ json: {'value':'error'} }] \n  }\n"
      },
      "name": "Function1",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        770,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Function1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}