Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Express and nodeJS: [Object: null prototype] { }

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?

like image 782
Jonathan Duarte Avatar asked Jan 31 '20 14:01

Jonathan Duarte


People also ask

What is object null prototype js?

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.

How do I make a prototype of an object?

getPrototypeOf() The Object. getPrototypeOf() method returns the prototype (i.e. the value of the internal [[Prototype]] property) of the specified object.

Why is null an object in JavaScript?

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.

What is object create in JavaScript?

The Object. create() method creates a new object, using an existing object as the prototype of the newly created object.


1 Answers

💡 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 🙏.

like image 100
Titus Sutio Fanpula Avatar answered Oct 17 '22 15:10

Titus Sutio Fanpula