hello I tried to use react-admin to display my API but I found this error
<–The X-Total-Count header is missing in the HTTP Response. The simple REST data provider expects responses for lists of resources to contain this header with the total number of results to build the pagination. If you are using CORS, did you declare X-Total-Count in the Access-Control-Expose-Headers header?—->
this is my backend code :
const PORT = 8000
const axios = require('axios')
const cheerio = require('cheerio')
const express = require('express')
const app = express()
const cors = require('cors')
app.use(cors())
const url= 'https://flyvide.com/airport/NCE'
//app.METHOD(PATH, HANDLER)
app.get('/', function (req,res) {
res.json('This is my webscrapper')
})
app.get('/results', (req,res) =>{
axios(url)
.then(response => {
const html= response.data
const $ = cheerio.load(html)
const articles = []
$('div > div > a > div' , html).each(function() {
direction = $(this).find("div > div.col-4.d-none.d-md-block > h5").text();
date = $(this).find("h5:nth-child(2)").text();
time = $(this).find("div.col-2.d-none.d-md-block > div > h5").text();
price = $(this).find("div.price.d-none.d-md-block > div > h4").text();
articles.push({
direction, date,time, price
//urls
})
})
//console.log(articles)
res.json(articles)
}).catch(err => console.log(err))
})
app.listen(PORT, () => console.log(`server running on PORT ${PORT}`))