Struggling to model this OpenAI cURL request in Node

cURL request:

curl \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -F purpose="fine-tune" \
  -F file="@mydata.jsonl"

Here’s what I’ve come up with. Crucially, I don’t want to read/send a file from my server, I want to create the file on the fly - and send it. I don’t want/need to save it to my server as an intermediary step (unless I have to?).

const fetch = require('node-fetch');
const FormData = require('form-data');
const fd = new FormData();
fd.append('file', 'this is my file content')
fd.append('purpose', 'assistants');
req2 = await fetch(
    '', {
        method: 'post',
        headers: {
            'Authorization': 'Bearer '+process.env.OPENAI_API_KEY,
        body: fd

I’ve tried creating the file new File(), but Node tells me that’s not a function. The above gives me:

  error: {
    message: 'The browser (or proxy) sent a request that this server could not understand.',
    type: 'server_error',
    param: null,
    code: null

Could anyone kindly help me with this? Thank you!