Closed zerobits-de closed 5 months ago
Hi, thanks for opening a PR!
I read the change, and I'm not sure if the error is an issue within the library. As you can see, the str
argument in the escapeUnicode signature already requires a string, so there should be no reason to use .toString()
on it. The only usage of the method is on Whatsapp.post(), and raw_body
should be a string | undefined
. Undefined is discarded a few lines above, so the only posibilities are either a string if you are following type check, or the method received something else that's not following type checking.
I would love to see what's your use case of the code, make sure the library is being used as expected, and then, if needed, hunt down the real issue and fix it.
Thanks for your help!
Thanks for coming back to me.
I double checked my code and it seems that my body is in binary. Converting the body with body.toString()
solved it for me.
public async receive(body: any, headers: any) {
console.log(body.toString());
return await this.wa.post(
JSON.parse(body ?? "{}"),
body.toString(),
headers["x-hub-signature-256"]
);
}
Awesome, happy to help 😄
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
npm run test
and lint the project withnpm run lint
andnpm run prettier
Fix
I got this error when parsing a message through
Whatsapp.post()
on version 3.0.0The PR fixed the error for me.