I want to display a variable from an extension called node temp mail its just a temp email generator i installed it using npm tell me if you want some more info I am new to webdev
i want the variable body
to display in the html or on the website itself
Here‘s the code:
var TempMail = require('node-temp-mail');
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i ) {
result = characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
var address = new TempMail(makeid(5),true);
address.fetchEmails(function(err,body){
console.log(body);
});
address.getAddress()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<script src="javasquript.js"></script>
<title>Debit Card Design</title>
</head>
<body>
<div >
<h4 >lightning <span>BANK</span></h4>
<div >
<h6>4512</h6>
<h6>8963</h6>
<h6>7845</h6>
<h6>3542</h6>
</div>
<img src="img/lightning.png" alt="" >
<img src="img/wave.png" alt="" >
<div >
<span>VALID<br>UPTO</span>
<h3>02 <span>/</span> 29</h3>
</div>
<div >
<span>CVC</span>
<h1>563</h1>
</div>
<img src="img/visa.png" alt="" >
</div>
<script type="module" src="javasquript.js"></script>
</body>
</html>
CodePudding user response:
You can create an empty div in html Like this:
<div id="add-value"></div>
and then in js you just set the content of the div like this:
document.getElementById('add-value').innerHTML = yourVariableName;
Please note that this will always override everything contained in the div.