20
Ich benutze das Request-Modul in Node.js, um eine Put-Anfrage zu machen. Mein Code sieht wie folgt ausNode.js - PUT mit Modul 'request'
var request = require('request');
var data = {foo: "bar", woo: "car"};
request({
method: 'PUT',
uri: myURL,
multipart: [{
'content-type':'application/json',
body: JSON.stringify(data)
}]
}, function(error, request, body){
console.log(body);
});
Als ich das laufen bekomme ich einen Fehler:
"Nicht unterstützte Inhalte mit Typ: application/json"
Das funktionierte wie ein Charme! Ich frage mich, warum die Dokumentation nicht so einfach war? – MonsterWimp757
Und wo würde ich Header hinzufügen? –
Header ist nur ein geschachtelter JSON in den Optionen JSON. – labyrinth