Join the Webstudio community

Updated 3 weeks ago

Access of URL Params

At a glance

The community member is trying to integrate Payload with Webstudio through the REST API, and wants to add the Live Preview feature. They have tried a specific URL format, but are unsure if it's the right way to use the parameters. Another community member provides a solution using system.search to check if the draft parameter is set to true and include it in the final URL.

Useful resources
I try to integrate Payload with webstudio through the REST-API this worked fine, but now i want to add the Live Preview Feature in Payload therefore I need to change the request url and add draft=true when my website get visited with mywebsite.com/blog/abc?draft=true at the moment I trid it like this:

"https://website.com/api/blog?where[slug][equals]=" + system.params.slug + "&depth=1" + (system.params.draft === true ? "&draft=true" : "")

Is there a way to use these params or what am i doing wrong?
Thank you!

https://website.com/api/blog?where[slug][equals]=${system.params.slug}&depth=1${system.search.draft == 'true' ? '&draft=true' : ''}

here the final expression if someone needs the same thing
View full solution
O
B
y
3 comments
yes, system.query
system.search
Thank you!

https://website.com/api/blog?where[slug][equals]=${system.params.slug}&depth=1${system.search.draft == 'true' ? '&draft=true' : ''}

here the final expression if someone needs the same thing
Add a reply
Sign up and join the conversation on Discord