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

130
Vistas
SyntaxError: Unexpected end of JSON input after call to Netlify function

i'm using Netlify serverless functions.

when I run JSON.parse on the event.body response I get SyntaxError: Unexpected end of JSON input

My client side code is as follows:


const items = [{ id: 'prod_LvqkrsI9O5F0xJ' }];

async function initialize() {
    const response = await fetch('/.netlify/functions/createPaymentIntent', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ items }),
    });
    console.log(response);
    const { clientSecret } = await response.json();

Server side code is as follows:

exports.handler = async (event, context) => {
    const items = await JSON.parse(event.body);
    console.log('items', items);

the console logs out

items { items: [ { id: 'prod_LvqkrsI9O5F0xJ' } ] }
...{"level":"error","message":"End - Error:"}
{"errorMessage":"Unexpected end of JSON input","errorType":"SyntaxError","level":"error",...

Any ideas please?

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