S
SolidJS11mo ago
MattS

Can the server$ call get access to the Request object?

I'm confused on why
createServerAction$(async (form: FormData, { request })
createServerAction$(async (form: FormData, { request })
has a request object but server$ does not. I'm trying to grab the current user when I do a server$ call, but I don't have any way to know what user it is because userServerContext() is {} and I don't see any way to get that data. I'm piling through the SolidStart source code right now but I don't see anything. I love Solid and Solid start but a few more examples in the documentation would really help.
7 Replies
MattS
MattS11mo ago
Meow?
Edivado
Edivado11mo ago
You should be able to access the request with server$.request
caseybaggz
caseybaggz11mo ago
createServerData$ also delivers the request object
MattS
MattS11mo ago
Wow that is a lifesaver!!! That worked perfectly! How on earth did you figure that out? I don't see any references to that in the documentation or anywhere on the internet actually It seems like createServerData$ is only meant to work on route nav, unless I'm missing someting. IN my case I don't want to nav. Edivado's solution works though thankfully.
lxsmnsyc
lxsmnsyc11mo ago
No, it can be used anywhere createServerData$ is just a combination of createResource and server$
MattS
MattS11mo ago
Weird okay. I don't see anything on the docs using it that way. I'll see if I can scrape up some examples on github or something. Thanks for the info.
Edivado
Edivado11mo ago
Should one in most cases stay away from server$? createServerData$ is according to the docs a wrapper around createRouteData + server$
Want results from more Discord servers?
Add your server
More Posts