For a hashing and verification purpose, raw body (without parsing) of a application/json
post request is needed.
Does loopback 4 provide any method for that? Request.body
is parsed as a json.
You can get the raw body by providing the following requestBodySpec
:
@post('/raw-body-post')
async rawBodyPost(
@requestBody({
description: 'Raw Body', // Description can be anything
required: true,
content: {
'application/json': { // Make sure this matches the POST request type
'x-parser': 'raw', // This is the key to skipping parsing
schema: {type: 'object'},
},
},
}) body: Buffer
) {
const rawBody = body.toString('utf8');
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With