druv5319 / Sneaks-API

A StockX, FlightClub, Goat, and Stadium Goods API all in one. This sneaker API allows users to search sneakers and track and compare prices while providing additional info such as product links and images
448 stars 118 forks source link

Error: Could not connect to StockX while searching #47

Open tylerwertman opened 1 year ago

tylerwertman commented 1 year ago

server.js:

app.get('/api/product', (req, res) => {
    const { sneakerName } = req.query;
    console.log(req.query)
    // Retrieve product details using "sneaks-api" package
    sneaks.getProducts({sneakerName}, 10, function(err, products){
        console.log(products)
    })
});

react component:

const handleSearch = () => {
        // Fetch the product information from the backend
        axios.get(`http://localhost:8000/api/product?sneakerName=${sneakerName}`)
            .then((response) => {
                // Store the product information in the component's state
                setProduct(response.data);
            })
            .catch((error) => {
                console.log('Error:', error);
            });
    };

console.log in server:

Error: Could not connect to StockX while searching '
    at Object.getProductsAndInfo (/Users/tyler/Desktop/code/codingDojo/PA/sneakerverse/server/node_modules/sneaks-api/scrapers/stockx-scraper.js:62:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
null

Seems it is hanging on StockX and not searching the other website. It woks fine in my backend as per npm website instructions but I want to implement front end functionality

thinheir commented 1 year ago

Unfortunately, StockX has deprecated this API version so it has broken this code. Hopefully there will be an alternative solution discovered or StockX will give access to a public API.

tylerwertman commented 1 year ago

Do you know why it works on the backend when I use it like this? I am getting info from StockX

const SneaksAPI = require('sneaks-api')
const sneaks = new SneaksAPI()

sneaks.getProducts("yeezy", 5, function(err, products){
    console.log(products)
})