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

243
Visualizações
Fetch Post Method Empty upon arrival at API

I am trying to send a web-push subscription object to my API, which consists of 'endpoint' and 'keys'.

The problem I seem to be having is when this object reaches my API it has the 'Keys' values but the 'endpoint' value is null. Yet when I debug it I can confirm that the endpoint value is defined.

This is the JS code I am using:

async function Subscribe() {
        let sw = await navigator.serviceWorker.ready;
        let push = await sw.pushManager.subscribe({
            userVisibleOnly: true,
            applicationServerKey:
                'ApplicationServerKeyHere'
        });
        console.log(JSON.stringify(push)); //Store this in DB

        fetch("https://localhost:44325/Subscribe", {
            method: "POST",
            //credentials: "same-origin", // include, *same-origin, omit
            headers: {
                "Content-Type": "application/json"
            },
            body: JSON.stringify(push)
        });
    }

endpoint is populated before the Fetch POST is sent:

enter image description here

And then empty when it arrives at the API:

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The incoming JSON has 'endpoint' as field while your DOTNET model class as 'enpoint' as field (mismatch in field names in json-payload and model class that will accept the json payload)

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