A simple HTTP server that returns previously posted JSON data
git clone https://github.com/moritzruth/http-json-store.git
cd http-json-store
HJS_TOKEN=YOUR_TOKEN_HERE npm start # or yarn start
docker build -t hjs https://github.com/moritzruth/http-json-store.git
docker run -d -p 3000:3000 -e HJS_TOKEN=YOUR_TOKEN_HERE hjs
version: '3'
services:
hjs:
build: https://github.com/moritzruth/http-json-store.git
ports:
- "3000:3000"
environment:
HJS_TOKEN: YOUR_TOKEN_HERE
Example using fetch:
// Get data
await fetch("http://localhost:3000").then(response => response.json())
// Set data
await fetch("http://localhost:3000", {
method: "post",
body: JSON.stringify({ yourData: "this can be anything" }),
headers: { 'Content-Type': 'application/json', "Authorization": "Bearer YOUR_TOKEN_HERE" }
})
If you are calling this from Node.js, you need to use node-fetch
.