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

219
Vistas
Why does fetching a .php file using post return a blank result

Okay, running this in a Node.JS enviornment (using node-fetch) works just fine, it returns the expected result.

fetch(`<URL>/api.php?f=developmentIsAnnoying2`,{method:"post",body:JSON.stringify({time:0,queue:["a song"],
repeat:false,loop:false})}).then(d=>d.text()).then(console.log);

But running the same code in Google Chrome, using the same domain, returns an absolutely blank result. There are no errors, on any side (client, php, nor API).

PHP:

    header("Content-Type: application/json");
    switch($_SERVER['REQUEST_METHOD']) {
        case "POST":
            echo file_get_contents('php://input');
        break;
        default:
            echo '{"message":"This is a place holder."}';
        break;
    }

What's the deal!?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

My last answer was removed by a moderator, so here's the answer again;

For some reason, it gets mad about the JSON header, despite the fact all data is ALWAYS supposed to be JSON, and was used that way in testing.

So, I had to remove this part:

header("Content-Type: application/json");
about 4 years ago · Juan Pablo Isaza Denunciar
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