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

155
Vistas
http: ¿cómo obtener json de la respuesta por lotes?

¿Cómo se obtiene json de la solicitud por lotes?

Recibo el siguiente error si consuelo. registro mi fetch response.json() :

Uncaught (in promise) SyntaxError: Unexpected number in JSON at position 3

Si me sumerjo en las fuentes de la red para ver la respuesta (by the way it has status 200) en devTools, veo la siguiente línea que produce el error:

 --batch_SuWHKrAohxj1o_r1qo6yzaAu-gfaqQ1p <-- producing error. Red lines underneath. Content-Type: application/http Content-ID: response- HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Vary: Origin Vary: X-Origin Vary: Referer { .......... .......... ......... }

Mi llamada fetch() tiene los siguientes encabezados:

 headers.append('Authorization', `Bearer ${token}`); headers.append('Host', 'www.googleapis.com'); headers.append('Content-Type', 'multipart/mixed; boundary="deel_foo"'); headers.append('Accept-Encoding', 'gzip'); headers.append('Accept', 'application/json');
 fetch(.....).then(response) => response.json())

cada solicitud por lotes dentro del cuerpo tiene Content-Type: application/json

EDITAR:
Quiero la siguiente respuesta.

 // stripped off the following: --batch_K_aZ7aQTR91ApoeMUayvTEJhZBs6PW9n Content-Type: application/http Content-ID: response- HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Vary: Origin Vary: X-Origin Vary: Referer // stripped off till here. { // I want this part, as it's valid JSON. "id": "17vegjeogjeogje44", "threadId": "17vjorgjerogjerogjer", "labelIds": [ "CATEGORY_UPDATES", "INBOX" ], "snippet": "Don&#39;t miss this idea and many more. Stash what matters to you and inspire others. \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c \u200c", "payload": { "partId": "", "mimeType": "text/html", "filename": "", "headers": [ ........ etc ........ etc........ }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Si alguien más enfrenta el mismo problema:

Pensé que había una respuesta singular con un cuerpo que contenía JSON. Técnicamente, hay una respuesta singular, pero está formateada como respuestas múltiples.

Las respuestas de varias partes en realidad contienen varias respuestas http, cada una con un header y un separador --[foobar] . No todos están concatenados dentro de un cuerpo contenedor y deben transformarse manualmente en datos utilizables mediante la aplicación de métodos de cadena/matriz o el uso de una biblioteca.

No existe una solución integrada para este equivalente a response=>response.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