Home Basic REST API with Nodejs and Express4
Reply: 0

Basic REST API with Nodejs and Express4

user7714
1#
user7714 Published in September 19, 2018, 7:20 pm

I have been trying to create a quick REST API using Nodejs and Express4 as I need an API quickly to make a prototype. While I need all basic CRUD operations, I tried to run the example from the following URL: http://runnable.com/U7bnCsACcG8MGzEc/restful-api-with-node-js-express-4 The example at this address only supports GET, but I believe I could quickly adapt it to support POST, PUT and DELETE. I do not care of having the data on memory, it is even preferable.

You can click to see the code there.

However, once I have started my server and go on http://localhost:8080/players

I get "Cannot GET /players" in my browser.

Any idea? If somebody has another short/quick example of a REST API with Nodejs with in-memory persistence, I'll take it as well :)

share|improve this question
  • did you do an "npm install" ? – Roy Sep 25 '14 at 19:02
  • 1
    Two points: first, in the example, the port used is 80, and not 8080. Second, you should try http://localhost:8080/api/players, or http://localhost:80/api/players (I don't know wich number you used). – Rodrigo Medeiros Sep 25 '14 at 19:03
  • @Roy Yes I did do an "npm install". – dukable Sep 25 '14 at 19:04
  • @Rodrigo - Yes, I have changed the port from 80 to 8080 in the server.js. Sorry I have forgot to mention that. You were right regarding the URL: localhost:8080/api/players works. Thanks! – dukable Sep 25 '14 at 19:05

2 Answers 2

active oldest votes
up vote 0 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.332108 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO