Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!