Skip to content

Instantly share code, notes, and snippets.

@zacharycarter
Last active February 27, 2018 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zacharycarter/3606beb3b5653f21c123d893c42dd2ba to your computer and use it in GitHub Desktop.
Save zacharycarter/3606beb3b5653f21c123d893c42dd2ba to your computer and use it in GitHub Desktop.
curl --request POST \
--url http://localhost:8082/foo \
--header 'content-type: application/json' \
--data '{
"bar": "FOOBAR"
}'
var express = require('express');
var bodyParser = require('body-parser');
var Gun = require('gun');
var gun = Gun('http://localhost:8082/gun')
gun.get('bar').on(function(data, key){
console.log(data, key)
})
var app = express()
app.use(Gun.serve)
app.listen('8080')
var express = require('express');
var bodyParser = require('body-parser');
var Gun = require('gun');
var gun = Gun('http://localhost:8080/gun')
var app = express();
app.use(Gun.serve)
app.use(bodyParser.json())
app.post('/foo', function(req, res) {
gun.get('bar').put(req.body)
res.sendStatus(200)
});
gun.get('bar').on(function(data, key){
console.log(data, key)
})
app.listen('8082')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment