Ich überprüfte alle Lösungen im Stackoverflow, aber sie funktionierten nicht mit mir Ich kann nicht verstehen, was passiert.Seltsame Fehler mit JSON in Knoten js
Hier mein Code ist:
var data = "";
req.on('data', function (chunk) {
data += chunk;
});
req.on('end', function() {
// Removed console.log() and after removing it didn't work so Please only answer my question and don't talk about silly things like a missing bracket -_!
//The error is here
var json = JSON.parse(data.toString());
switch (json.method) {
...
}
});
Und Konsolausgabe hier:
verwenden Ist der Wert von data.toString() tatsächlich gültige JSON? – nnnnnn