Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

403
Views
Undefined body of a fetch request (arraybuffer body) in node server

I've read a lot of similar questions, but any answer worked for me.
I'm trying to send an audio in the body of a fetch request (in vuejs) as an ArrayBuffer, but when I print it in the server side, the body is undefined.
Client code:

export async function makeQuery(data) {

    let bufferAudio = await data.arrayBuffer();
    console.log(bufferAudio);

    const response = await fetch(`/api/query`, {
        method: 'POST',
        //headers: {'Content-Type': 'audio/mp3'},
        body: bufferAudio,
    })
    .catch(function(e) {
        console.log("error", e);
    });

    return response;
}

Node Server code:

const express = require('express');
const path = require('path');
const app = express(), port = 3080;

app.post('/api/query', async (req, res) => {
  query = req.body;
  console.log('query ', query); // Here the body is undefined
  
  /*
  Do some processing...
  */

});

When I send a simple json string in the request body (and app.use(express.json()) in the server)it works. But not with the arraybuffer audio. Thanks in advance

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!