melonpan icon indicating copy to clipboard operation
melonpan copied to clipboard

Parse body request

Open SimbaNinja917 opened this issue 2 years ago • 1 comments

How can I parse the JSON from a POST request ? The code below isn't working


melonpan.post("/user" , (req, ctx) => {
    let user_request = req.json().then((data) => {
       console.log(data);
    });
    // console.log(user_request);
    return ctx.json({status: "ok"});
});

SimbaNinja917 avatar Jan 28 '23 08:01 SimbaNinja917

i've used npm body-parser . but it is not working . is the solution for this ?

ReadableStream {
  [Symbol(state)]: 4,
  [Symbol(reader)]: undefined,
  [Symbol(storedError)]: undefined,
  [Symbol(disturbed)]: false,
  [Symbol(readableStreamController)]: null,
  [Symbol(bunNativeType)]: 4,
  [Symbol(highWaterMark)]: undefined,
  [Symbol(underlyingSource)]: undefined,
  [Symbol(start)]: [Function],
  cancel: [Function: cancel],
  getReader: [Function: getReader],
  pipeTo: [Function: pipeTo],
  pipeThrough: [Function: pipeThrough],
  tee: [Function: tee],
  values: [Function: values],
  [Symbol(Symbol.asyncIterator)]: [Function: lazyAsyncIterator]
}

bobwatcherx avatar Jan 29 '23 03:01 bobwatcherx