Setting the url with multiple, interpolated binded-values triggers a request even if not all bindings have been defined when auto is set to true
Expected outcome
<iron-ajax url="[[baseUrl]]/users/[[idUser]]>" triggers an auto-request when both baseUrl and idUser have been defined.
Actual outcome
<iron-ajax url="[[baseUrl]]/users/[[idUser]]>" triggers a request when baseUrl is defined but beforeidUser has been defined, resulting in a request like so:
http://foo.com/users/ instead of http://foo.com/users/3
Steps to reproduce
Described above
Notes
Now to be clear -This can be solved in many ways - setting up an observer of some sort, a method to check the url value, or maybe a computed property that waits until all properties are defined.
For example I could do this:
<iron-ajax method="GET" url$="{{_processUrl(baseUrl, endpoint)}}" auto></iron-ajax>
<script>
...
_processUrl: (baseUrl, endpoint) => {
// @HACK checking if the `url` has all interpolated props set properly.
// If it contains `//` or ends with `/` we infer that some of the binded props
// have not been defined yet.
if (endpoint.includes("//") || (endpoint.endsWith("/"))) return false;
return baseUrl + "/" + endpoint;
}
</script>
and usage:
<foo-x endpoint="user/[[idUser]]"></foo-x>
However, I'd much prefer if I didn't have to write boilerplate code for trivial use cases like this one. If auto is really gonna be useful it should work for basic real-world cases like this one
Description
Setting the
url
with multiple, interpolated binded-values triggers a request even if not all bindings have been defined whenauto
is set totrue
Expected outcome
<iron-ajax url="[[baseUrl]]/users/[[idUser]]>"
triggers an auto-request when bothbaseUrl
andidUser
have been defined.Actual outcome
<iron-ajax url="[[baseUrl]]/users/[[idUser]]>"
triggers a request whenbaseUrl
is defined but beforeidUser
has been defined, resulting in a request like so:http://foo.com/users/
instead ofhttp://foo.com/users/3
Steps to reproduce
Described above
Notes
Now to be clear -This can be solved in many ways - setting up an observer of some sort, a method to check the
url
value, or maybe a computed property that waits until all properties are defined.For example I could do this:
and usage:
However, I'd much prefer if I didn't have to write boilerplate code for trivial use cases like this one. If
auto
is really gonna be useful it should work for basic real-world cases like this oneBrowsers Affected