I'm creating a small app with node.js and have stumbled upon a problem. I am trying to send an img to all users from my admin account. The problem is I can't seem to show my image through javascript appending to the div I made . Is it because I'm working with pug that it doesn't render my image?
My admin side
document.querySelector('#Function1').addEventListener("click", function (e) {
alert('hi mom');
primus.write({message: 'function1'});
//console.log(id);
e.preventDefault;
});
My client side
var image = "images/logo.png";
primus.on("data", function (data) {
if (data.message != undefined) {
if (data.message == 'function1') {
document.querySelector("#functionShow").append("<img src="+image+"/>");
} else {
console.log('something went wrong');
}
}
});
This is the end result shown
welkom Hanna
<img src=images/logo.png/>
Nah, it's not pug's fault, pug is innocent of this crime :)
What you're missing are quotes around "images/logo.png", it should be
It's because browsers are trying to access "logo.png" as a folder now.