Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

215
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda