Uncaught Error: Undefined constant "image" - json

I've an error when i execute the API JSON :
This is my code :
$image = get_the_post_thumbnail_url($post);
if (!image) {
$image = "";
}
And the error :
Uncaught Error: Undefined constant "image" in C:\xampp\htdocs\app\wp-content\themes\twentytwenty\functions.php:873
thx

There is an issue in this line.
if (!image) {
.. it should be.
if (!$image) {
It is a weird logic though because it says that when the $image is undefined or empty, empty it or assign a blank string literal to it.

Related

setAttribute is undefined ,why?

This is my code follow:
[in html]```
```
[in css]```
.myclass {
width:50%;
}```
[in js] function changewidth() { let mynodes = document.getElementsByClassName('.myclass'); mynodes.setAttribute('width','100%'); }
then, when this function be run, it display:
Uncaught TypeError: Cannot read properties of undefined, when reading 'setAttribute'
what happen and how to correct ?
thanks
The error says that the myNodes variable is undefined meaning JavaScript cant find it anywhere because it doesn't exist.
Remove the dot(.) in
document.getElementsByClassName('.myclass')
It should be
document.getElementsByClassName('myclass')

Uncaught TypeError: Cannot read properties of undefined (reading 'quote') at XMLHttpRequest.xhr.onload

can anyone tell me what i'm doing wrong?
document.getElementById('output').innerHTML = `
"${quotes[randomNum].quote}" - ${quotes[randomNum].character} <br>
${quotes[randomNum].pic}
`;
}
}
i didn't think I need to define quote because its in my json

convertFromRaw giving this error "Invariant Violation: invalid RawDraftContentState"

I want to convert html code to draft object to save my editorState
But convertFromRaw function giving me Invariant Violation: invalid RawDraftContentState <- this error.
try {
const htmlToDraftObject = htmlToDraft(
post.content
);
console.log(htmlToDraftObject);
console.log(convertFromRaw(htmlToDraftObject));
} catch (error) {
console.log(error, "error");
}
console.log(htmlToDraftObject);
this line is returns this object
{"contentBlocks":[{"key":"apdo3","type":"unstyled","text":"\"\\n","characterList":[{"style":[],"entity":null},{"style":[],"entity":null},{"style":[],"entity":null}],"depth":0,"data":{}},{"key":"2lgc","type":"unstyled","text":"","characterList":[],"depth":0,"data":{}},{"key":"118p1","type":"atomic","text":" \\n","characterList":[{"style":[],"entity":"5526de6f-06fd-445d-9ae4-e5bae145adab"},{"style":[],"entity":null},{"style":[],"entity":null}],"depth":0,"data":{}},{"key":"13tke","type":"unstyled","text":"\\n\"","characterList":[{"style":[],"entity":null},{"style":[],"entity":null},{"style":[],"entity":null}],"depth":0,"data":{}}],"entityMap":{"5526de6f-06fd-445d-9ae4-e5bae145adab":{"type":"IMAGE","mutability":"MUTABLE","data":{"src":"\\\"https://p.bigstockphoto.com/GeFvQkBbSLaMdpKXF1Zv_bigstock-Aerial-View-Of-Blue-Lakes-And--227291596.jpg\\\"","alt":"\\\"undefined\\\"","height":"","width":""}}}}
post.content is a simple html code
I tried it without htmlToDraft function too .But it gave me another error
what am I doing wrong?

VueJS search filter error: cannot ready 'search' of undefined

I'm building an app to consume a json and list it with a search filter input and other stuff.
I've already tried to create the function but it didn't work.
Codesandbox URL
https://codesandbox.io/s/vue-template-7iev3?fontsize=14
search: "",
Its showing "TypeError: Cannot read property 'search' of undefined" but its defined
TypeError: Cannot read property 'search' of undefined" doesn't mean that "search" is undefined but the parent object is. In your case, "this.search", this is undefined in your callback. You should use "self.search" because you already defined it or just change your syntax into:
computed: {
produtoFiltrado: function() {
return this.produtos.filter((cust) => {
return cust.nome.match(this.search);
});
}
}
Arrow functions doens't bind their "this" to their context so you can access your vue methods, props, data etc. using this without any problems
To avoid "TypeError: Cannot read property 'includes' of null" problem, better to add line before return
computed: {
filteredItems() {
return this.customers.filter(item => {
return (item.title || '').toLowerCase().indexOf((this.search || '').toLowerCase()) > -1
})
}}
(this.search || '') will do trick..

Why as3 giving me syntax error in a for loop?

I'm new with actionscript and I keep getting syntax error with the following for loop:
for each (target:Target in targets) {
if(target != null) {
target.parent.removeChild(target);
}
}
And I got this error message:
Syntax error: expecting in before colon.
What is the problem?
You forgot to declare the variable, it should be:
for each (var target:Target in targets) {
// …
}
Note the var.