Is there anyway how can I get query string in Polymer?
http://localhost:8080/search?param=ppshein
I want to get search?param=ppshein
or param=ppshein
in Polymer.
I've tried to get query string in app-route
but it display nothing.
<app-route
route="[[route]]"
pattern="/:id"
data="{{routeData}}"></app-route>
[[routeData.id]] **
A query string is the portion of a URL where data is passed to a web application and/or back-end database. The reason we need query strings is that the HTTP protocol is stateless by design. For a website to be anything more than a brochure, you need to maintain state (store data).
A query string commonly includes fields added to a base URL by a Web browser or other client application, for example as part of an HTML, choosing the appearance of a page, or jumping to positions in multimedia content.
Query string parameters are useful tools when accessing information from APIs. In the most basic cases, using the correct query strings can limit the number of responses returned while others have the ability to embed multiple tables and databases with one endpoint.
You could use <app-location>.queryParams
:
<app-location route="{{route}}" query-params="{{queryParams}}"></app-location>
queryParams
is an object containing key/value pairs of the parsed query parameters. Given http://localhost:8080/search?param=ppshein
, queryParams
would be:
{
param: 'ppshein'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With