Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we need Express server when we have a backend ready already

I am quite new to javascript and web application environment. I have seen a react web application project which had a public directory, a client directory and a server directory. I have few question

  1. Why do we need an express server file setup in the frontend project if we already have backend APIs ready and backend server ready

  2. Do we need an express server if we make the frontend on react and call the APIs to fetch the data for application.

  3. Isn't the backend server and express server in the frontend project are same?

like image 910
EdG Avatar asked Jan 31 '17 06:01

EdG


People also ask

Why do we use Express server?

Express provides methods to specify what function is called for a particular HTTP verb ( GET , POST , SET , etc.) and URL pattern ("Route"), and methods to specify what template ("view") engine is used, where template files are located, and what template to use to render a response.

Is Express used for backend?

Express. js is the most popular backend framework for Node. js, and it is an extensive part of the JavaScript ecosystem. It is designed to build single-page, multi-page, and hybrid web applications, it has also become the standard for developing backend applications with Node.

Why do we require Express?

It is used for designing and building web applications quickly and easily. Web applications are web apps that you can run on a web browser. Since Express. js only requires javascript, it becomes easier for programmers and developers to build web applications and API without any effort.

Is Express used for frontend or backend?

js, or simply Express, is a back end web application framework for Node. js, released as free and open-source software under the MIT License. It is designed for building web applications and APIs.


1 Answers

Why do we need an express server file setup in the frontend project if we already have backend APIs ready and backend server ready

You don't.

You need an HTTP server to listen for and respond to any Ajax requests you make from your client side code.

You need an HTTP server to listen for and respond to any requests for the HTML documents and static resources (JS, CSS, images, etc) that your pages need.

These can be the same HTTP server, different HTTP servers, written with Express or not written with Express.

React tutorials tend to ignore mentioning this and just dive in showing how to use Express for everything. Don't read too much into that.

Do we need an express server if we make the frontend on react and call the APIs to fetch the data for application.

No. See above.

Isn't the backend server and express server in the frontend project are same?

Maybe. It is up to you. See above.

like image 130
Quentin Avatar answered Sep 22 '22 07:09

Quentin