I am a beginner in web development.I am using angular framework ,need to connect with DB using Nodejs. I am able fetch data from db using NodeJs. How to connect this with my front end code
2 Answers
You have a front-end and a backend, note that front-end is not a necessity just a web front-end, it might be a mobile application as well.
Your server should be able to send back data to be helpful for any kind of programming languages in front-end, either it's a mobile app, or a React or Angular application. For this scenario and to solve this problem we can use RESTful API (Application Programming Interface) which simply is a JSON sending back data from the backend, and front-end applications can work with it.
For your case, you should connect to the database using Node.js backend (I recommend you to use a Node.js framework, such as Express, Feathers, Strapi, or etc) and send data back in RESTful API format,

- 5,188
- 7
- 37
- 61
You can fetch data from nodejs using ajax request. Follwoing link may help you to learn this:
Ajax Request in Angular from jquery $.ajax to angular $http You can use mysql module in nodejs for fetching data from your database.
As a newbie, you can do the above steps and then follow some tutorial that teaches how to do all this.

- 596
- 5
- 12