The following code works fine if the "canLogin" property exists.
this.canLogin$ = this.permissions$.pipe(pluck('canLogin'));
If the property doesn't exist, I get this error:
ERROR TypeError: Cannot read property 'canLogin' of undefined
How can I check for null or return null if the property doesn't exist?
I tried something like this but it doesn't work
this.canLogin$ = this.permissions$.pipe(pluck('canLogin')) || of(false);
That's not because the property doesn't exist. The error is because permissions$ emits undefined and that can't have any property.
So you can do something like for example:
this.canLogin$ = this.permissions$
.pipe(
map(obj => obj || {}),
pluck('canLogin'),
);
Related
Error:
TypeError: Cannot read property 'roles' of null
at Object.process (/home/bots/fortnite-bot/commands/stats/stats.js:19:33)
Line (stats.js):
let platform = message.member.roles.find(x => (x.id === psnRoleId) || (x.id === xboxRoleId))
Help please....
Since Discord.JS v12 came out, instead of message.member.roles.find(), you must instead use message.member.roles.cache.find(). The function works in exactly the same way in the context you're using it, you just need to add the .cache in there.
I'm getting some data from a json file and with .map putting those points on a google maps in reactjs, all fine. But some of the items in the object don't have any values and if they get called they throw a: 'TypeError: Cannot read property 'category' of null'. Shouldn't I just be able to do something like the following in the return:
{ marker.outcome_status.category && <p>Outcome: {marker.outcome_status.category} ({marker.outcome_status.date})</p> }
Since you have 2 nested levels you need to check there is marker.outcome_status as well.
{
marker.outcome_status
&& marker.outcome_status.category
&& <p>Outcome: {marker.outcome_status.category} ({marker.outcome_status.date})</p> }
i have code like following
_this.data.opt[compId]
here the compid value is 1. when this value comes one means the javascript error cannot read the property 1 of undefined at compid.
When I want to use model like this:
console.log($scope.selectedMonth);
I get output:
Object { no: "02", name: "Veljača", $$hashKey: "object:24" }
But when I want to use one of its properties like this:
console.log($scope.selectedMonth.name);
I get error:
Error: $scope.selectedMonth is undefined
Why is that happening and how do I access model object properties?
When object was initialized it was undefined by default. This line of code is inside $watch method and I added if statement that fixed the problem.
if ($scope.selectedMonth !== undefined) {
console.log($scope.selectedMonth.name);
}
I am trying to edit a number of cells in the grid. I am able to edit all cells except one cell. All cells have same data type i.e. string. When I click on that particular cell, I get the error
Uncaught TypeError: Object #<error> has no method 'indexOf' in ext-all-dev.js
in the following block:
urlAppend : function(url, string) {
if (!Ext.isEmpty(string)) {
return url + (url.indexOf('?') === -1 ? '?' : '&') + string;
}
During debugging, I can see that the value of 'url' in the code block
shown above is set to 'true'.
It is clear from this that 'true' does not have the method 'indexOf'.
But I am unable to understand why the URL is being set as true. The console errors do not point to any of the JS files created by me. How can I find what I am doing wrong?