Categories
JavaScript Answers

How to convert Node.js MongoDB object id to string?

Spread the love

To convert Node.js MongoDB object id to string, we call the toString method.

For instance, we write

console.log(user._id.toString());

to call toString to convert the _id object ID to a string.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *