https://github.com/twlite/rest-api-example
Simple and easy to use rest api example.
https://github.com/twlite/rest-api-example
Last synced: 13 days 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 (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-31T09:41:40.000Z (over 5 years ago)
- Last Synced: 2025-06-28T13:56:16.546Z (14 days 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)