Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Could not connect to StockX while searching #47

Open
tylerwertman opened this issue Jun 25, 2023 · 2 comments
Open

Error: Could not connect to StockX while searching #47

tylerwertman opened this issue Jun 25, 2023 · 2 comments

Comments

@tylerwertman
Copy link

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
Copy link

thinheir commented Aug 4, 2023

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
Copy link
Author

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)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants