#maverickdoge_webhooks

1 messages ¡ Page 1 of 1 (latest)

nocturne garnetBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1278060682037825628

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

fiery flume
final plover
#

If you do payload.body do you get the same error?

nocturne garnetBOT
final plover
#

What happens when you console.log(); request? Does it contain anything?

fiery flume
#

yes when I console.log header and body it contains the data

#

same with payload.body

unkempt rapids
#

what happens if you just pass payload to constructEvent instead?

fiery flume
#

still getting type error since its expecting string but payload is type ReadableStream<Uint8Array>

unkempt rapids
#

Ah wait, why is it a Readable Stream though?
is the request being parsed somewhere before it hits your function?

It should be a buffer

fiery flume
#

so I am parsing it as string but still error for not able to verify

unkempt rapids
#

you shouldn't do request.text

#

try request.rawBody

#

also asking the same question as above
is the request being parsed somewhere before it hits your function?

fiery flume
#

So the webhook is hitting directly the endpoint and the constructEvent func is getting params as u can see in the pics

#

if u mean parsing in the middleware than its not doing that

unkempt rapids
#

Correct. You only shared your code for Post function.. Where exactly are you calling this function?

#

middleware meaning if you're passing a body parser or something to your node server, that's a middleware

#

something that automatically converts incoming request body to let's say JSON

#

Can you share the code that configures your route?

fiery flume
#

So I am running it next js, I have a middleware running but that does not parse anything so the request should directly hit the function, so the request is the raw request

unkempt rapids
#

rawBody is a property, not a function

#

Guessing Next wraps Request object into it's own wrappers

fiery flume
#

now the only error I am getting is for invalid body

#

do u maybe know about that?

unkempt rapids
#

What did you try out exactly?
I'm guessing you're passing something invalid to constructEvent

fiery flume
#

So I added the micro lib to read it as buffer and than providing that as string to constructEvent

unkempt rapids
#

try removing toString() and just passing a buffer

#

you could also try printing the buffer to make sure its actually a buffer