I am a beginner in web dev and I am developping a web app using firstly Node.JS to scrape restaurants informations from two websites (Maitres Restaurateurs and Guide Michelin), then ExpressJS to begin the app. I use res.sendFile() function to display my HTML page then res.json() to send a JSON file in the HTML page.
First, here is my work dir (It's a mess):
src
├server.js
├index.html
├server-side
├bib.js
├jsx
├react.jsx
server.js code (where i get in the listFinal variable a JSON object with all my restaurants informations scraped with puppeteer on the two website. It was done thanks to bib.js):
const express = require('express');
const app = new express();
const bib = require('./server-side/bib');
var listFinal = bib.get();
app.get('/', function (req, res) {
res.sendFile('./index.html', {root: __dirname});
res.send(listFinal);
});
app.listen(8000, function () {
console.log('Example app listening on port 8000!');
});
The server is working good. However none of my HTML or my React code is working (I'm completly new to React). The only thing displayed on my HTML is my huge JSON stored in the variable listFinal. The list has a length (or size) of 50 and here is its structure:
[{"name": "Saperlipopette ",
"url": "www.saperlipopette1.fr",
"address": "9 place du Théâtre, Puteaux, 92800, France",
"price_style": "36 - 65 EUR • Cuisine moderne",
"phone": "+33 1 41 37 00 00"},
...]
My index.html code:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Session 3 Work - Axel Joly</title>
<meta name="description" content="Bib gourmand + Maitre restaurateur scrappeur">
<meta name="author" content="Axel Joly">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<h1>Welcome to the Bib Gourmand and Maitre Restaurateur list (made by Axel Joly):</h1>
<div id="root">
<ul id="list-rest">
</ul>
</div>
<script src="./jsx/react.jsx"></script>
</body>
</html>
And my react.jsx code:
var React = require('react');
var ReactDOM = require('react-dom');
export class Hello extends React.Component {
render() {
return (
<h1>Welcome to React!!</h1>
);
}
}
ReactDOM.render(<Hello />, document.getElementById('root'));
As explained before, none of them are displayed.
When I run node server.js and go to localhost:8000/, I've got this:
As you can see, there is no <h1> header rendered, both normally displayed with React and HTML. Also, I don't know how to "retrive" my variable listFinal in the HTML to render it as a li with <ul> and <li> tags.

jsxfile to run the react code what you wanna do is create a react app vianpx create-react-app clientwhich would contain the client-side code then i would recommend usingconcurrentlyto run both the client-side and the server-side at the same time. ( i could set this up for you if you are willing to put the current code oncodesandbox)