-1

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

varnit
  • 1,859
  • 10
  • 21
Amal Raj
  • 29
  • 1
  • 1
  • 5

2 Answers2

1

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,

Mohammad Kermani
  • 5,188
  • 7
  • 37
  • 61
0

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.

Ankit Agrawal
  • 596
  • 5
  • 12