Cannot read property 'backgroundColor' of undefined - properties

When the function call below gets run it returns this error.
"Uncaught TypeError: Cannot read property 'backgroundColor' of
undefined" I am trying to change the background color of a class called
.jumbotron. I have tried everything I can thing of so far.
Could anyone tell me why this is happening?
clrElementJumbo("cornsilk");
function clrElementJumbo(scolor) {
var el = document.getElementsByClassName("jumbotron");
el.style.backgroundColor = scolor;
}

Try to replace the code
var el = document.getElementsByClassName("jumbotron");
with the following
var el=document.getElementsByClassName("jumbotron")[0];

Related

Uncaught (in promise) TypeError: src is undefined

I would like to ask for some help with my javascript code.
When my trigger is an tag and plain text inside it, it works. But for structural reasons I had to use a tag inside my , and that way I'm getting an error, "Uncaught (in promise) TypeError: src is undefined".
Here's the part of the JS code that the error is referring to:
// destructure values
const { link, src, artist, title, moodcover } = e.target.dataset;
const peaksSrc = src.replace('.mp3', '.json');
const res = await fetch(peaksSrc);
const { data: peaks } = await res.json();
wavesurfer.load(src, peaks);
document.body.scrollTop = 0;
What would be the solution for this problem?
Thanks in advance!
I've tried using or instead of , but that didn't help.

Cannot read property 'authorizationUrl' of undefined

Im trying to get consentUrl but getting "Cannot read property 'authorizationUrl' of undefined".
Im using "xero-node": "^4.1.2"
const xero = new xero_node.XeroClient({
clientId: "clientId",
clientSecret: "clientSecret",
redirectUris: ["redirectUrl"],
scopes: "offline_access,openid".split(",")
});
then inside async function i'm calling this:
let consentUrl = await xero.buildConsentUrl();
and it gives error : Cannot read property 'authorizationUrl' of undefined.
Should I create url manually if this function is not supported. Need help thanks.
try to execute await xero.buildClient();
before let consentUrl = await xero.buildConsentUrl();

ERROR TypeError: Cannot read property 'project_name' of undefined - Angular 8

My ts code coding is,
this.api.getPay(this.donationId).subscribe(
data => {
this.paymentData = data;
this.paymentDetails = this.paymentData.donationDetails[0];
}
)
My html code is like
Project : <strong>{{paymentDetails.project_name}}</strong><br/>
Status: <strong>{{paymentDetails?.status}}</strong><br/>
Now project_name and Status details will be displayed. Console gets "ERROR TypeError: Cannot read property 'project_name' of undefined"
If I added "?" like
{{paymentDetails?.project_name}}
No Details displayed. But console not having any Error.
This same coding method works well in Angular 5/6.
Any special method for Angular 8 ???
MY console output in TS file is
{
project_name: "test",
status: "true"
}
Previous question is How to Display Values in Angular 8 Shows ERROR TypeError: Cannot read property 'project_name' of undefined
but solution not working
anyone know how to resolve ?
Everything seems good, check if your component doesn't have
changeDetection: ChangeDetectiongStrategy.OnPush
If so, remove it and put back the '?' in the html markup, and then add it back and do the change detection in the subscribe

i am getting an error on using tf.frompixels recently which i wasnt getting before. below is the code i am using

function preprocessImage(img) {
const tensor = tf.fromPixels(img)
.resizeNearestNeighbor([224, 224]);
const croppedTensor = cropImage(tensor);
const batchedTensor = croppedTensor.expandDims(0);
return batchedTensor.toFloat().div(tf.scalar(127)).sub(tf.scalar(1));
}
the error i am getting is that tf.fromPixels is not a function . i wasnt getting this error as of two weeks back but i am suddenly getting this error on running the same code.
It looks like tf.fromPixels() has been removed and its function taken over by tf.browser.fromPixels().
Source

Sencha touch List clean data

I have following code.
var list = this.getNavigation();
if (list.itemsCount > 0) {
list.removeAll(true, true);
}
list.setData(filtered);
List = xtype: list.
So idea is next i have menu and some times i need to rebuild it. as you see i am not using store because i need to filter array and set it.
When i call removeAll i got error
Uncaught TypeError: Cannot call method 'getScroller' of undefined
And i cant find method to cleanup it...
I rewrote my menu to use store and instead of setData on list i am setting data on store and it works as expected
Another option would be calling removeAll with destroy set to false like so:
var list = this.getNavigation();
if (list.itemsCount > 0) { list.removeAll(false); }
list.setData(filtered);
The list DOM items get deleted anyways by some sort of auto-cleanup.