How to pass Query Params?
See original GitHub issueHey guys,
I’ve been working on a project using Zoid for a bit now but I’m a bit hung up on how to properly pass query parameters.
Do I pass them in the URL of the page that the xcomponent is being rendered on? I’m passing them on the parent page where the component is being rendered such as: www.example.com/index.htm?make=honda&model=civic&maxprice=20000
However, I’m getting an error the make
is required so doesn’t seem like the props are being consumed.
What am I missing here?
Login component defined
var MyLoginXComponent = xcomponent.create({
// The html tag used to render my component
tag: 'my-login-component',
// The url that will be loaded in the iframe or popup, when someone includes my component on their page
url: xcomponent.getCurrentScriptDir() + '/login.htm',
dimensions: {
width: '500px',
height: '1000px'
},
props: {
make: {
type: 'string',
queryParam: true // ?email=foo@bar.com
},
model: {
type: 'string',
queryParam: true
},
maxprice: {
type: 'string',
queryParam: true
}
},
scrolling: true,
autoResize: true
});
JS File
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/4.0.2/bootstrap-material-design.css" />
<link rel="stylesheet" href="../../common/login.css" />
<!-- Pull in xcomponent and the login component we defined -->
<script src="../../../dist/xcomponent.js"></script>
<script src="./login.js"></script>
</head>
<body>
<div id="vehicleDisplay"></div>
<script>
var make = window.xprops.make;
var model = window.xprops.model;
var maxPrice = window.xprops.maxprice;
console.log("Hey - Value: ", {
make: make,
model: model,
maxPrice: maxPrice
});
</script>
</body>
Parent Page rendering xComponent
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/4.0.2/bootstrap-material-design.css" />
<link rel="stylesheet" href="./common/index.less" />
<script src="example.com/xcomponent.min.js"></script>
<script src="example.com/login.js"></script>
</head>
<body>
<h3>Best bang for your buck | Honda Vehicles</h3>
<div id="container">
<script type="application/x-component" data-component="my-login-component"></script>
</div>
</body>
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Query Parameters - Branch.io
Query parameters are a defined set of parameters attached to the end of a url. They are extensions of the URL that are...
Read more >How to pass two query parameters in URL - Stack Overflow
How to pass two query parameters in URL ; @PUT @Path("/buy") ; public Response buyTicket ; Projection projection ; = projectionDAO.findById(Long.
Read more >URL parameters - How to pass it to the destination URL
You can pass URL parameter values to your tracking destination URL using the options available in ClickMeter. ... You can also add multiple ......
Read more >How to Send Query Params in GET and POST in JavaScript
To send query parameters in a POST request in JavaScript, we need to pass a body property to the configuration object of the...
Read more >Working with Query Parameters in Rest Assured | REST API
Note: If you need to send multiple query parameters you simply need to append queryParam() method with the parameter name and value to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’d probably want to do something like:
(I know this is a little janky. I’m not the hugest fan of the
<script>
style integration; considering removing it in a future major release in favor of justMyLoginXComponent.render()
since it doesn’t add a whole lot of value)Cool! Let me know if any more questions come up 😃