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

109
Vistas
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 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