[src] attribute the first time it calls to an undefined endpoint
See original GitHub issueGET http://localhost:8080/undefined 404 (Not Found)
<img [src]="data.avatar_url" width="100" height="100"/>
this.data = {};
http.get('https://api.github.com/users/danicomas').toRx().map(res => res.json()).subscribe(response => this.data = response);
Issue Analytics
- State:
- Created 8 years ago
- Comments:23 (15 by maintainers)
Top Results From Across the Web
React/Redux reducer returned undefined during initialization
I have a console.log() at the beginning and it is not being called at all. reducers/reducer_which_sorter.js import { SORT_CAMPERS } ...
Read more >Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >also, Platform API Endpoint /api/v2/conversations/calls/history ...
Hello, We are trying to use OpenDataExporter to get participant data values. Similarly to the other post in the Developer forum on this ......
Read more >Queries - Redux Toolkit
Query endpoints are defined by returning an object inside the ... indicates that the query is currently loading for the first time, ...
Read more >Setting up Axios Interceptors for all HTTP calls in an application
A lot of the time, those HTTP calls aren't so simple either: I ... the first argument passed to the response interceptor is...
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 Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
The solutions above did not work for me for this situation:
[src]='getImageUrl() | async'
before the promise is resolved, I have a momentarily null value that causes the request to be triggered anyway. The solution that worked for me and can easily cover the above scenarios too is:
[attr.src]='getImageUrl() | async'
I mentioned this subtlety in this issue https://github.com/angular/angular/issues/3007 (for me it was making
/null
requests) the current workaround is|| ''
soor default the initial
avatar_url
value to empty string (probably a good idea anyways).I would say if interpolation gets to have a default case of empty string then
[src]
should as well. Here’s my code