Estoy tratando de simplemente usar jQuery en mi proyecto npm en el lado del servidor. Quiero poder cambiar los valores en mi HTML/establecerlos a través de mi base de datos. Pero por mi vida no puedo averiguar cómo declarar o requerir las variables necesarias. Por favor ayuda y explica!
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>