'How can I take multiple dynamic values from a get function in JS, and output it on HTML?

I am using an API to get certain data about shoes.

The getProdcuts function takes the parameters and returns them. The values here are "Yeezy" and 2. What the forEach function does, is take the values returned for 2 yeezy products, and gets the official name of the shoe (products.shoeName).

const { Agent } = require('http');
const { listenerCount } = require('process');
const SneaksAPI = require('sneaks-api');
const sneaks = new SneaksAPI();



//getProducts(keyword, limit, callback) takes in a keyword and limit and returns a product array 
sneaks.getProducts("Yeezy", 2, function (err, products){
    products.forEach(function shoeName (products) {
        console.log(products.shoeName);
    });

});

I have been desperately trying to get a way to set these names to HTML text. It works when I console.log, but does not work when I use:

 const { Agent } = require('http');
    const { listenerCount } = require('process');
    const SneaksAPI = require('sneaks-api');
    const sneaks = new SneaksAPI();
    
    
    
    //getProducts(keyword, limit, callback) takes in a keyword and limit and returns a product array 
    sneaks.getProducts("Yeezy", 2, function (err, products){
        products.forEach(function shoeName (products) {
            document.getElementById("text").innerText = products.shoeName;
        });
    
    });

That returns this error message:

Error: Could not connect to Goat while searching 'AQ4211-101' Error: 
    at Object.getLink (c:\Users\tallt\node_modules\sneaks-api\scrapers\goat-scraper.js:27:17)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Is this an issue specific to the API? Is there an alternate solution I could try? Please let me know if you need more details.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source