title: JS alert popup randomly showing up
body: <p>I've got a function to post via <code>axios</code> which is supposed to popup an alert afterward to indicate if everything's OK or not.
  The thing though is that it shows up randomly, whether it is a success or not.</p>
  <p>Here is the code, let me know if more is needed.</p>
  <p>I'm new on this site so please let me know if I'm doing wrong, should post somewhere else, or anything.</p>
  <p>I start to wonder if my controller is the one messing with my &quot;res&quot;...</p>
  <pre><code>postButton.addEventListener('click', function sendPost() {
      let formData = new FormData();
      if (document.querySelector('#actu').checked === true) {
          formData.append('title', document.getElementById('title').value);
          formData.append('authorId', localStorage.getItem('userid'));
          formData.append('category', document.querySelector('input[name=&quot;category&quot;]:checked').value);
          formData.append('message', document.getElementById('message').value);
          formData.append('pinned', document.querySelector('input[name=&quot;pinned&quot;]:checked').value);
          formData.append('image', document.getElementById('image_input').files[0]);
      } else if (document.querySelector('#presse').checked === true) {
          formData.append('title', document.getElementById('title').value);
          formData.append('authorId', localStorage.getItem('userid'));
          formData.append('category', document.querySelector('input[name=&quot;category&quot;]:checked').value);
          formData.append('message', document.getElementById('message').value);
          formData.append('pinned', document.querySelector('input[name=&quot;pinned&quot;]:checked').value);
          formData.append('image', document.getElementById('image_input').files[0]);
          formData.append('link', document.getElementById('pdf_input').files[0]);
      };
  
      axios({
          method: 'post',
          url: 'http://localhost:3000/user/post',
          data: formData,
          headers: {
              'Content-Type': 'multipart/form-data',
              'Authorization': 'Bearer ' + localStorage.getItem('token'),
          }   
      })
      .then((res) =&gt; {
          let post = document.createElement('tr');
          post.classList.add('row'+ res.data.id);
          let date = new Date(res.data.date);
          let dateParse = new Date(date).toLocaleString('fr-FR', {
              day: 'numeric', // numeric, 2-digit
              month: 'long', // numeric, 2-digit, long, short, narrow
              year: 'numeric', // numeric, 2-digit
          });    
          post.innerHTML = `
              &lt;td class=&quot;id_row&quot;&gt;${res.data.id}&lt;/td&gt;
              &lt;td class=&quot;title_row&quot;&gt;${res.data.title}&lt;span class=&quot;tooltiptitle&quot;&gt;${res.data.title}&lt;/span&gt;&lt;/td&gt;
              &lt;td class=&quot;author_row&quot;&gt;${res.data.authorid}&lt;/td&gt;
              &lt;td class=&quot;date_row&quot;&gt;${dateParse}&lt;/td&gt;
              &lt;td class=&quot;array_buttons&quot;&gt;
                  &lt;input type=&quot;button&quot; class=&quot;edit_button&quot; value=&quot;modifier&quot; class=&quot;edit&quot; onclick=&quot;edit_row(${res.data.id})&quot;&gt;
              &lt;/td&gt;
              &lt;td class=&quot;array_buttons&quot;&gt;
                  &lt;input type=&quot;button&quot; class=&quot;delete_button&quot; value=&quot;effacer&quot; class=&quot;delete&quot; onclick=&quot;delete_row(${res.data.id})&quot;&gt;
              &lt;/td&gt;
                  `;
          if (res.data.category === 'actus') {
              tableBodyActus.appendChild(post);
          } else if (res.data.category === 'presse') {
              tableBodyPress.appendChild(post);
          };
          console.log(res.data);
          alert(res.data.message);
          location.reload();
      })
      .catch((err) =&gt; {
          console.log(err);
          alert(err.response.data.message + '\n' + 'Raison invoqué : ' + err.response.data.message2)
      })
  })
  
  ///////////////////////////////////////////////////////////////////////
  
  exports.postArticle = (req, res) =&gt; {
      if(req.body != null &amp;&amp; req.files != null) {
          for (let i = 0; i &lt; req.files.length; i++) {
              if (req.files[i].fieldname === 'image') {
                  req.body.image = req.files[i].filename;
              } else if (req.files[i].fieldname === 'link') {
                  req.body.link = req.files[i].filename;
              }
          }    
          let dataPost = {
              authorid: req.body.authorId,
              title: req.body.title,
              message: req.body.message,
              // Pour production :
              // image: `${req.protocol}://${req.get('host')}/images/${req.file.filename}`, 
              image: `${req.protocol}://127.0.0.1:5500/back/datas/images/${req.body.image}`,
              link: `${req.protocol}://127.0.0.1:5500/back/datas/pdf/${req.body.link}`,
              category: req.body.category,
              pinned: req.body.pinned,
          }
          clanaDb.query('INSERT INTO actualites SET ?', dataPost,  (err, resultat) =&gt; {
              if(err) {
                  console.log(err); 
                  res.status(501).json({ message: 'Erreur de transmission.'});
                  throw err; 
              }
              return res.status(201).json({ message: 'Merci pour votre Post !'});
          })
      } else {
      return res.status(501).json({ message: 'Erreur de validation.'});
      }
  };````
  </code></pre>