Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

406
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda