Include variable in JSON block’s API URL
-
Can I adjust the API URL used by the JSON Content Gutenberg block in response to variable passed in the containing page’s URL? Example use case:
— a page at URL /states has a JSON Content Gutenberg block that calls an API to request a list of US state names (e.g. api.com/states/all)
— the block displays each returned state name as a clickable link having URL like /cities?state=ca
— JSON Content Gutenberg block on /cities page calls api with request for cities in the selected state (e.g. api.com/[state]/cities/all)
In other words, would I need 50 pages with blocks having hard-coded API URLs, or can I have one page where the block’s API URL incorporates a passed variable?
- The topic ‘Include variable in JSON block’s API URL’ is closed to new replies.