Sum two integers
In this example, we’ll send two integers in the request body, calculate their sum, and return the result. This example showcases how to access and handle request data in FaasPlus.
const handleRequest = async (req) => {
const a = req.body.a || 0;
const b = req.body.b || 0;
const sum = a + b;
return {
'sum': sum
};
};
body (as json)
{
"a": 10,
"b": 20
}
> response
{
"sum": 30
}