-
-
Save chapel/824792 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var req = http.request({ | |
host: '127.0.0.1', | |
port: '5984', | |
path: '/ms/', | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json' // Need to add headers object | |
}}, function(res){ | |
var sigma = ''; | |
res.on('data',function(chunk){sigma+=chunk}) | |
res.on('end',function(){ | |
console.log(sigma); //{"error":"bad_content_type","reason":"Content-Type must be application/json"} | |
var reply = JSON.parse(sigma); | |
if(reply.ok == "true") | |
callback(reply.id); | |
else | |
callback(null); | |
}) | |
}); | |
var data= JSON.stringify({'type':'file','modul':doc._id,'author': author, 'downloads':0}) | |
console.log(data); //{"type":"file","modul":"28d946b681df8ab17c2010193e001172","author":"Niklas Fischer","downloads":0} | |
req.end(data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@vs1145146:/var/www/mitschriften# curl -X POST -H "Content-Type: application/json" -d '{"type":"file","modul":"28d946b681df8ab17c2010193e001172","author":"Niklas Fischer"wnloads":"0"}' 127.0.0.1:5984/ms/ | |
{"ok":true,"id":"28d946b681df8ab17c2010193e004bf9","rev":"1-5ffe477691071504ca55bfa9fb997dd4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment