Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/twlite/rest-api-example
Simple and easy to use rest api example.
https://github.com/twlite/rest-api-example
Last synced: about 1 month ago
JSON representation
Simple and easy to use rest api example.
- Host: GitHub
- URL: https://github.com/twlite/rest-api-example
- Owner: twlite
- License: mit
- Created: 2020-01-31T09:22:46.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-31T09:41:40.000Z (almost 5 years ago)
- Last Synced: 2024-09-20T00:28:38.432Z (about 2 months ago)
- Language: HTML
- Homepage: https://inex07.github.io/rest-api-example/
- Size: 228 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# [REST API EXAMPLE](https://inex07.github.io/rest-api-example/)
Simple and easy to use rest api example.# Methods
- GET
- POST# Setup
- Download this project
- Open `powershell` or `cmd` on the project location
- run `npm install`
- run `npm start`
- Open browser
- Go to `https://localhost:3000`# Examples [ Fetching ]
- GET
```js
const fetch = require("node-fetch");fetch("https://localhost:3000/api/ping")
.then(res => res.json())
.then(body => console.log(body));
```- POST
```js
const fetch = require("node-fetch");fetch("https://localhost:3000/api/something", {
method: "POST"
})
.then(res => res.json())
.then(body => console.log(body));
```- Headers
```js
const fetch = require("node-fetch");fetch("https://localhost:3000/api/something", {
method: "POST",
headers: {
"authorization": "abcABC123"
}
})
.then(res => res.json())
.then(body => console.log(body));
```# Website Preview
[Click Me](https://restapiexample.glitch.me)![preview](https://raw.githubusercontent.com/INEX07/rest-api-example/master/assets/image.png)