Hi, maybe this is an easy question, but it was not possible for me to find a satisfying solution:
there is a GET-request sent to an object in strapi (finance-suggestions)
this request contains payload the body
the tag “content-length” contains the correct size of the payload
But: Accessing this content is not possible. There is no “undefined” error thrown, but the object is just empty when putting it to console for example:
The important part here is, that a semaphore (in shape of a new created promise) will handle the runtime state of the true readout.
Now the second part is to implement the call of this new created function there where the ctx - object is located while runtime:
await getBody(ctx.req)
.then( ( bodydata ) => { console.log(bodydata) } )
.catch( (error) => { console.log("There was an error reading out the body" + error) } )
It is further needed to impement a better error handling. In the case of sending empty or no body or a non-json one, the call of JSON.parse() will fail. But in all, with the code above it is possible to read out the raw content of the body. Hope it helps you and that the code written is human-readable.