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

114
Visualizações
C# Oscova Bot failing on await response.json()

I am trying to work out a C# implementation of the Oscova bot (described in the tutorial); however, when it goes to process the message which is done with an await fetch('...url') and the response is received via await response.json() during the response it is writing the json onto the page ahead of the <!Doctype> tag and causing all further javascript to fail to execute as it throws the SyntaxError: Unexpected token < in JSON at position ... error.

I tried changing the process to:

await fetch('url').then(response => response.json()).then(data => respObj = data);

Then based on other SO articles tried changing the response.json() to response.text(). The response.text() doesn't cause an error but then the rest of the method fails because it sends back a json object and most of the page html text all run together in one string which the method can't process. I've also tried altering the fetch to make sure it posts and accepts a header of 'application/json' which doesn't work either.

The json object that's getting written to the page looks something like this:

{ "success": true, 
    "id": "134566878976413", 
    "user": "user", 
    "response": { 
      "item1": "", 
      "items": [], 
      "item2": "text", 
      "item3": "text", 
      "item4": "text", 
      "item5": "" 
}, 
"item6": 1.0 }

How can I prevent the json from being written to the page or if it's supposed to be able to be written to the page keep it from causing the syntax error?

about 4 years ago · Juan Pablo Isaza
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