« first day (3663 days earlier)      last day (1270 days later) » 

10:09 AM
@NickVN Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
@GretchenRichards This comment might help you: github.com/feross/simple-peer/issues/426#issuecomment-459780844
 
 
7 hours later…
5:03 PM
Oi
 
 
1 hour later…
6:21 PM
I've this code in a service.
console.log(this.cache.Ads.find(x => x.priority == 124));
let ads: Ads | undefined = this.cache.Ads.find(x => x.priority == 124 && x.placement == placement && x.shown == false);
And getting this error
{type: "a", priority: 124, link: "https://www.link.com", placement: 0, image: Array(1), …} api.service.ts:601
{type: "a", priority: 124, link: "https://link.com", placement: 0, image: Array(1), …} 3ads.component.ts:58
TypeError: Cannot read property 'priority' of undefined
    at api.service.ts:602
    at Array.find (<anonymous>)
    at api.service.ts:602
    at new ZoneAwarePromise (zone-evergreen.js:876)
    at ApiService.getNonPriorityAds (api.service.ts:600)
    at AdsComponent.ngOnInit (ads.component.ts:44)
This is where I'm getting error
this.cache.Ads.find(x => x.priority == 124
                            ^^^^^
However this.cache.Ads contains 30+ entries
Any idea why it says Cannot read property 'priority' of undefined
As a temporary fix, I used this.cache.Ads.find(x => !!x && x.priority == 124. I'd like to know why this happens
 
7:05 PM
it probably doesn't contain 30+ entries at that point in time
hence the error
err
well, the entries aren't what you expect them to be, anyway
there's defeinitly entries, as otherwise .find would have failed with a similar error
 
7:18 PM
When I run console.log(this.cache.find(..., it works
It
 
but... the error message.
it says x is undefined.
at least one value in Ads is undefined, that's the only way that error occurs
 
yo js room o/
 
o/
 
Ahhh yeah. Thanks Kevin.
I'm using resolve(undefined) instead of rejection if no entries found in a firestore call to bypass Promise.all rejection
While pushing it to cache service, I forgot to write check for undefined. All other functions contains the following code data = data.filter(x => x); before pushing to cache. but I missed it on this function.
 
 
3 hours later…
10:12 PM
 

« first day (3663 days earlier)      last day (1270 days later) »