0

I am using ElectronJS and below is my function that returns data from mongo database (in the main process) :

ipcMain.on('getRequests', (event) => {
  return Requests.find({});
});

Requests in the database has attributes like date, and time.

in the frontend (renderer process), I have the following:

<div id="page-inner">
            <div class="row">
                <div class="col-md-4 col-sm-4">
                   <div class="card teal">
                        <div class="card-content white-text">

                          <span class="card-title">Attribute1</span>

                          <p>Attribute2</p>

                        </div>
                        <div class="card-action">

                          <a href="#">Attribute3</a>

                          <a href="#">Attribute4</a>
                        </div>
                      </div>
                </div>
            </div>
         </div>

How can access the elements returned from getRequests function?

I know about ipcRenderer. I thought about doing something as follow:

<script>
const ipcRenderer = require('electron').ipcRenderer;
ipcRenderer.send('getRequests');
</script>

I am not sure if the above is correct but even if it was, how will I change the value of Attribute1, Attribute2, ... based on the returned value?

NOTE: I am using mongoose

Behrouz Riahi
  • 1,751
  • 2
  • 21
  • 42
  • MongoDB or Mongoose? Because there is a notable difference in the result of `.find()`. Also it's an "async" function in either case, so you do not simply `return`. – Neil Lunn Aug 03 '17 at 01:53
  • @NeilLunn Mongoose, sorry, will update the question now. – Behrouz Riahi Aug 03 '17 at 01:56
  • @NeilLunn do you know how to get I can retrieve the attributes of Reequests in the client side? – Behrouz Riahi Aug 03 '17 at 01:57
  • I think you really should read [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) as the more pressing issue here. – Neil Lunn Aug 03 '17 at 01:57

0 Answers0