Nilegfx / json-server-answer-417

This repo is an answer for json-server's issue number 417
3 stars 0 forks source link

This repo is a response for one of json-server questions

running the exampl

git clone https://github.com/Nilegfx/json-server-answer-417.git

cd json-server-answer-417

npm install

node server

make a request with basic authentication

from your command line, run

curl -u yourusername:yourpassword http://localhost:3000/posts

responses with status 200:

{
  "user": "yourusername",
  "body": [
    {
      "id": 1,
      "title": "first post title",
      "name": "ahmed ayoub"
    }
  ]
}

a request without basic authentication

from your command line, run

curl http://localhost:3000/posts

responses with status 401:

{
  "error": "unauthorized"
}