data not sending in mongodb
Answered
rkstlohchab posted this in #help-forum
i tried add
to Params but still it didnt worked well ,
i used clerk to send the user data > to server action > then database
but it didnt worked
@Clown @"use php"
string | nullto Params but still it didnt worked well ,
i used clerk to send the user data > to server action > then database
but it didnt worked
@Clown @"use php"
Answered by "use php"
Summary:
- The issue was caused due to middleware
- Further, it was caused due to fact Clerk was not providing
- The issue was caused due to middleware
- Further, it was caused due to fact Clerk was not providing
firstname & lastname387 Replies
the warning is clearly stating the issue is with type
in firstName, add
string | nullstill it is not working
@"use php" in firstName, add `string | null`
the error goes away but
the user is not
passed on to
db
the event was fired at the api endpoint
that basically means that you can't get
first_user to be nullmeans you'll have to verify if first_user has a value
i tried this
the code worked but the data is not in db still
Console log response from mongodb
@rkstlohchab Click to see attachment
A suggestion, you can just use .toObject function to convert to object
Send console log of new user
there is no log
i think the data is not passed through
In catch error just console.error(error)
scroll up to the error
if you want, you can give vscode share link
what to do to reproduce err
@rkstlohchab
I fixed the warning
Just customise the response message later on
like in json if needed
and what action to do to check webhook?
@rkstlohchab
what bro?
@"use php" I fixed the warning
what did u do
?
how to check the
webhook event
right?
yes, you said item was not getting added to db
wait that can only be accessed on deployed version
lemme check
@rkstlohchab wait that can only be accessed on deployed version
the clerk webhook uses
endpoint
for webhook event
that works well on deployed version
wait 1 min
ohk
?
Send production logs
are you sure the latest version is deployed?
yes
i just deployed 4 mins ago
Can you first use https://smee.io/ to test webhook locally?
@"use php" Can you first use https://smee.io/ to test webhook locally?
lemme try if i can do it
what exactly is this used for i didnt quite understood
You can use it to test webhook locally
yes
should i setup
yes
target should be
http://localhost:3000/api/webhookbro just to be clear i want to ask
we can not add local host directly in clerk i mentioned that earlier
I mean
the url
@rkstlohchab now what do i have to do to get the webhook
url in this page
...
I'll give you a webhook url, just set it to that
rest I'll setup
done
@"use php" https://smee.io/4KpGJSHF4V1UsqJD
In clerk, set it to this
can you try giving a request now?
the data is paased on to
smee
was the user created?
yes
user was created
and the
webhook was fired at
smee
at this url
but it wasnt updated in db
wait lemme see
can you CTRL+C the terminal where you ran smee?
i did
wait don't' run again
ohkky
wait a min
now try
I ran in my system
wait 1 min, I think there is some bug with code or somethin
there is a 404 error in development also
yea
you can see the app terminal
we are using smee currently
Its because of middleware.ts
its a ignored route
@"use php" i see what you did wrong
whats that
wait I'm confused
should we ask moderator?
@rkstlohchab don't ping moderator
okay
so @rkstlohchab its some bug with the middleware only
ohh
I added
/api/webhook in public Routenot sure if its supposed to be there, just confirm once
Can you try sending request now?
try sending request
in clerk
damn
lemme try brother
so lame of me
well
the object was created in db
thats a good start
but there is no data
can you try now?
can you set webhook url to smee url?
if not ady
to this in clerk https://smee.io/4KpGJSHF4V1UsqJD
make q req
@"use php" make q req
u can also do that by creating deleting updating user
we are at 220+ messages. please wrap things up soon.
alright
@joulev we are at 220+ messages. please wrap things up soon.
we are trying our best
if u can help we would be happy to accept it
@"use php" how can you send data to db using smee ?
you can't
smee is just like a proxy
I'm not sure why clerk is sending a webhook to delete data
but not on my webhook
i also tried
deleting
user
don't try for now
my user accnt
it is passing
i thinkg
null data
thats why it is not getting updated on db
check terminal
that you'll have to fix
wait lemme check
i enabled that
it was disabled by default
previously
it used to be enabled
let it be disabled for now
You can add it later on
in updated they changed it again
update it later on
🫠
check the data @rkstlohchab
database
i enabled clerk firstname lasstname
it should work just fine now
I'm not sure what you mean
I'll test it out
@"use php" the webhook url is still that url, right?
now i changed it to
deplyed site
change it back to https://smee.io/4KpGJSHF4V1UsqJD
done
first name and last name is optional fyi
it impports data
with
the sign in from google
alright
first name and lastname arent option
check database?
it worked
finally
but it is not working for my endpoint
why is that
Check env
check vercel logs
if i didnt updated env
then ur smee wouldnt have worked
lemme tell u
for example the
you updated in production
dont reveal it
can you try pushing now, and just check?
xyz is on local host and on vercel deployement
i changed the webhook url for tha same
xyz key
in clerk
getting ?
code
it'll console.log the error then
change to prod
failed again
vercel log
did you add a first name?
that indicates data is missin
did u logged in using gmail or manual data
gyou can see above the request on webhook logo
@rkstlohchab did u logged in using gmail or manual data
I logged in using manual data
so should I make it optional then
or you can make it optional
i ll break the code again
dont forget to update params and model
ohkaaay buddy
Summary:
- The issue was caused due to middleware
- Further, it was caused due to fact Clerk was not providing
- The issue was caused due to middleware
- Further, it was caused due to fact Clerk was not providing
firstname & lastnameAnswer
you got the option now, nice
oh alright
You can also [sponsor me](https://github.com/sponsors/anay-208/) for my efforts
Let me know if you have any other issue!
@"use php" You can also [sponsor me](<https://github.com/sponsors/anay-208/>) for my efforts
you are also from india?
ohkayy
i am also from india
alright
#off-topic
yepp