Building a Web API with Express and PostgreSQL to Consume from Browser

  • 577

Building a Web API with Express and PostgreSQL to Consume from Browser

We have made a video about how to connect to #postgres from javascript. we have used #nodejs as the javascript runtime which can create executable that run, query the database and display your results. However, a lot of you asked how can I connect to postgres from my browser? The answer is no! The reason is browser only know how to make web calls which are HTTP calls while database is a low level tcp protocol. So we need some layer that can serve HTTP calls, serve web calls, almost like a web server.

In this video use express which sets on top of node js to spin up a web server and serves an API which will allow us to communicate from our browser to our postgres database this is coming up.

  • [ ] Setup Postgres database

  • [ ] Setup NodeJS and Express

  • [ ] Write TODO list API

    • [ ] Implement GET (return all todos)
    • [ ] implement POST (create new todo)
    • [ ] implement DELETE (delete a todo)
  • [ ] Build the HTML web page that consumes the API

  • [ ]

github repo -
https://github.com/hnasr/javascript_playground/tree/master/express-postgres