I tried to scrape amazon product details using scraping api but it shows me following error:
"message": "Error: getaddrinfo ENOTFOUND api.scrapapi.com",
"cause": {
"errno": -3008,
"code": "ENOTFOUND",
"syscall": "getaddrinfo",
"hostname": "api.scrapapi.com"
},
My whole code snippet is given below. Please help me to fix this problem
const { response } = require('express');
const express = require('express');
const { reset } = require('nodemon');
const request = require('request-promise');
const app = express();
const PORT = process.env.PORT || 5500;
const apiKey = "api_key";
const apiUrl = `http://api.scrapapi.com?api_key=${apiKey}&autoparse=true`;
app.use(express.json());
app.get('/',(req,res) =>{
res.send('Daraz api scraper');
});
//get product id
app.get('/products/:productId',async(req,res)=>{
const {productId} = req.params;
try {
const response = await
request(`${apiUrl}&url=https://www.amazon.com/dp/${productId}`);
res.json(JSON.parse(response));
} catch (error) {
res.json(error);
}
});