I am trying to simply use jQuery in my npm project on the server side. I want to be able to change the values in my HTML/set them via my database. But i cannot for the life of me figure out how to declare or require the needed variables. Please help and explain!
var jsdom = require("jsdom");
var JSDOM = jsdom.JSDOM;
var window = new JSDOM("${__dirname}/homepage/index.html").window;
global.document = window.document;
const $ = require( "jquery" )( window );
//Test upload to mongodb
//Get Random Index of 'Released Pokemon' For It's Pokedex #ID
const releasedPokemon = [1,4,7,10,13,16,19,21,23,25,27,29,32,35,37,39,41,43,46,48,50,52,54,56,58,60,63,66,69,72,74,77];
app.post('/catch', async function(req, res) {
//Catch random pokemon
$(document).ready('#catchPokemon').hide(300);
const index = Math.floor(Math.random() * releasedPokemon.length);
const dex = releasedPokemon[index];
const pokemon = await PokeAPI.pokeAPI(dex)
console.log(pokemon);
});
<form method="post" action="/catch">
<button style="background-color: Transparent;" onclick="catchPokemon()">
<img type="image" src="https://i.imgur.com/zs02wMs.png" alt="Catch Pokemon"
width="100" height="100">
</button>
</form>