Giter VIP home page Giter VIP logo

sandbox-api's Introduction

Sandbox-API

Practice making http requests on your local machine

Tutorial

This tutorial will explain how to use Postman to send requests to ourserver

Setting up server

First clone down the sandpox-api repo

git clone https://github.com/jmarthernandez/sandbox-api

Next make sure that we are in the sandbox-api directory and run

npm install

What this does is install all of the required modules(things we need) for our express server to run. The main three are express and body-parser. Express is a framework that lets us spin up servers very quickly. Body-parser allows our express server to read the requests that Postman will be sending

The last thing we need to do is run the command

node app.js

This will start our server. Now we can make requests to it.

Postman

Postman is availible as a chrome extension so go ahead and install that.

##Endpoints

GET localhost:4000/messages
  Returns an array of all the messages in the database
  
POST localhost:4000/messages/
  Adds a message to the database

GET localhost:4000/messages/:messageNumber
  Retrieves a message from database
  or returns an error stating message doesn't exist
  
PUT localhost:4000/messages/:messageNumber
  Updates a message to the database
  or returns an error stating message doesn't exist
  
Delete localhost:4000/messages/:messageNumber
  Deletes a specific message from the database
  or returns an error stating message doesn't exist
  
  ***** :messageNumber is an actual number.

Request Time

In Postman we will be using x-www-form-urlencoded whenever we POST or PUT to our server. Whenever we POST or PUT we will be using message as our key and whatever you want for the value.

Try playing around with the different HTTP methods and endpoints. Also, there are comments throughout the source code that give a little more context.

Have fun!

sandbox-api's People

Contributors

jmarthernandez avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.