title: How do I convert an image to a base64-encoded data URL in sails.js or generally in the servers side JavaScript?
body: <p>I am making a small app in <code>sails.js</code> and I need to store images in database. For that, I need to convert an image to a base64-encoded data URL so that I can save it as a string in my sails models. However, I don't know how to convert it in this form. All the older questions asked about converting an image to base64-encoded data URLs, and they answer this about doing it on the client side.  However, I want to do it on the server side while I will be getting the image through a post request.  How can I achieve this?</p>