When I make a post request returns - undefined
request:
curl --location --request POST 'http://localhost:8000/api/register?name=Jose&[email protected]&password=123456'
--header 'Content-Type: multipart/form-data; boundary=something'
export const Register = async (ctx: Context) => {
const { name, email, password } = await ctx.request.body().value;
try {
ctx.response.body = { name: name , email: email , password: password };
//return: {} undefined
} catch (err) {
ctx.response.status = 404;
ctx.response.body = { msg: 'error' };
}
}
The kind of data that you're transferring is suitable for a simpler encoding scheme like JSON. Here's a self-contained demo:
./so-71455993.ts:
: