title: Sending data from MongoDB to my EJS file without refreshing the page?
body: <p><strong>Project goal:</strong> I am trying to create a language converter app. It will take a string from one textarea, convert all string values via a stored dictionary on a DB, and append this converted string into a second textarea. All of this conversion will be happening on the same <strong>index.ejs</strong> page (<strong>no refreshing/redirecting/etc.</strong>).</p>
  <p><strong>What works:</strong> I am able to POST the string data from my first textarea to <strong>index.ejs</strong> and retrieve all matching dictionary entries in my <strong>app.js</strong>. The &quot;/&quot; path (shown below) is my <strong>index.ejs</strong> file. The values are stored in an array called &quot;convertArrOfArrs&quot;.  I am using <strong>Mongoose</strong> to do this on my <strong>app.js</strong>. I have prevented the page from infinite refreshing (due to my POST request) via <strong>res.status(204).send()</strong>.</p>
  <p><strong>What doesn't work:</strong> I can't figure out how to send this array of converted values (&quot;convertArrOfArrs&quot;) to my <strong>index.ejs</strong>. I think res.render() doesn't work since I need to stay on the same page.</p>
  <p>This is my <strong>app.js</strong> which deals with the POST request.</p>
  <pre><code>app.post(&quot;/&quot;, async (req, res) =&gt; {
    // entire textarea string
    const txtareaStr = await req.body.phoneticTxtArea;
    // puts string into an array, lowercases it, and removes whitespaces
    const txtareaArr = txtareaStr.trim().toLowerCase().split(&quot; &quot;);
  
    const convertArrOfArrs = [];
    try {
      for (let i = 0; i &lt; txtareaArr.length; i++) {
        // this retrieves the word object based on the database match
        let word = await Word.findOne({ phonetic: txtareaArr[i] });
        // stores array of conversions for each word (ARRAY TO BE SENT!!!)
        convertArrOfArrs.push(word.converted);
      }
    } catch (e) {
      console.log(&quot;ERROR&quot;, e);
    }
    // prevents page from infinite refreshing after POST request
    res.status(204).send();
  });
  </code></pre>
  <p>Please let me know if any other details are needed!</p>