Join the Webstudio community

Updated 3 months ago

Is there any way to dynamically insert a string into another string, inside Global Data Variables?

At a glance

The community member is building a template to access an API that requires a key matching a dedicated store, which changes with every project. They are looking for a way to change a single string, the "dedicated Store Slug", and have that populate into the Resource API call, so they only need to change that one string for each project. The comments suggest using a template string with a variable to achieve this, but the community member tried it and got an invalid URL error. Another community member mentioned using backticks, but the community member had trouble getting that to work correctly in the expression editor.

Use Case:
I'm building out a template for myself to access an API. The API requires a key matching a dedicated store (changes with every project).

Is there a way to change a single string, call it the dedicated Store Slug, and then have that populate into the Resource API call?

This way, all I'll have to do on a project is to change the dedicated Store Slug and all else will populate.
O
t
7 comments
you need to use a variable inside of a string and that string is part of a resource, right?
if I understand corrrecly your use case you just need to use a template string in the binding
Plain Text
`asomething${variable}something`
Yes, this is what I was trying. And I probably don't understand the context, but I tried adding that to the URL portion of the Resource call but get an invalid URL.
Attachment
image.png
It's one of those mornings.... I put in backticks but didn't do it in the expression editor. The backticks in the text box turned to apostrophes instead.
Add a reply
Sign up and join the conversation on Discord