I have this problem, when I receive a request in the server the response is:
[Object: null prototype] { '{"someParameter": "potatoParameterValue", "someOtherParameter": "otherPotatoParameter}': '' }
I already used
api.use(bodyParser.urlencoded({ extended: false }));
api.use(bodyParser.json());
and that doesn't work,someone else has had the same problem?
Object with null prototype and its purposeIf you create an object in JavaScript - it has some methods by default, such as toString(), keys() or hasOwnProperty(). But that is true when you create an object based on default Object.
getPrototypeOf() The Object. getPrototypeOf() method returns the prototype (i.e. the value of the internal [[Prototype]] property) of the specified object.
The JavaScript specification says about null : null is a primitive value that represents the intentional absence of any object value. If you see null (either assigned to a variable or returned by a function), then at that place should have been an object, but for some reason, an object wasn't created.
The Object. create() method creates a new object, using an existing object as the prototype of the newly created object.
💡 The only one reason why you get something like this:
[Object: null prototype]
it's because{ extended: false };
👨🏫 Now, you try to change your extended
to true
. For an example, you can look at this code below:
app.use(bodyParser.urlencoded({ extended: true}));
I've been try that code above and it's working fine
I hope it can help you 🙏.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With