Fetch and upload an image via express

I want to fetch an image from an URL and then upload it to Cloudflare Images. But I keep getting a 400 error. Can someone please take a look at my code and tell me what’s wrong with it?

const response = await axios.get(url, { responseType: 'stream' });

  const form = new FormData();
  // Pass image stream from response directly to form
  form.append('image', response.data, 'kitten.jpg');

  try {
    const postRes = await axios.post(`https://api.cloudflare.com/client/v4/accounts/${process.env.ACCOUNT_ID}/images/v1`, form, {
      headers: {
        Authorization: `Bearer ${process.env.API_KEY}`,
    console.info('response', postRes);
  } catch (error) {
    console.error('Error while uploading to cloudflare', error);

Here is the error I’m getting:

Error while uploading to cloudflare Error: Request failed with status code 400

That’s embarrassing . My API_KEY wasn’t defined. Problem solved

Hi! how are you? I’m running the exact same code, but getting this error 'ERROR 5400: Bad request: Error parsing form fields\n'… did you know what it can be? Thanks