<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: dev-shubham098</title>
    <description>The latest articles on Forem by dev-shubham098 (@paradox098).</description>
    <link>https://forem.com/paradox098</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F784077%2Ff2704703-0efe-4667-9888-a116c2dec5bf.png</url>
      <title>Forem: dev-shubham098</title>
      <link>https://forem.com/paradox098</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/paradox098"/>
    <language>en</language>
    <item>
      <title>Need Help 🙏 unable to delete cookie in Express</title>
      <dc:creator>dev-shubham098</dc:creator>
      <pubDate>Mon, 11 Apr 2022 19:15:45 +0000</pubDate>
      <link>https://forem.com/paradox098/need-help-unable-to-delete-cookie-in-express-4o93</link>
      <guid>https://forem.com/paradox098/need-help-unable-to-delete-cookie-in-express-4o93</guid>
      <description>&lt;p&gt;Hello everyone 👋 I am a newbie working on a full stack web app using node, express and mongodb in the backend for my final semester project. &lt;/p&gt;

&lt;p&gt;I am working on an admin portal, when users (admins) sign in a cookie is stored in the browser and a token (using json web tokens here) is stored in the mongodb, but I am unable to delete the cookie during logout.&lt;/p&gt;

&lt;p&gt;My logout code is :-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.get("/logout", auth, async (req, res) =&amp;gt; {
  try {

    req.user.tokens = req.user.tokens.filter((currentElement) =&amp;gt; {
    return currentElement.token !== req.token })

    res.clearCookie("jwt");
    console.log("Logout Successful");

    await req.user.save();
    res.render("/");

  } catch (error) {
    res.status(500).send(error);
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Authorization code :-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const auth = async (req, res, next) =&amp;gt; {
    try  {
        const token = req.cookies.jwt;
        const verifyUser = jwt.verify(token, process.env.SECRET_KEY);
        console.log(verifyUser);

        const user = Register.findOne({ _id :verifyUser._id});
        console.log(user.firstname);

        req.token = token;
        req.user = user;

        next();     

    } catch (error) {
        res.status(401).send(error);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Logout only gives this output :-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zmNiIC3v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqb7lj0zyp73k6vhe3ik.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zmNiIC3v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqb7lj0zyp73k6vhe3ik.jpg" alt="Image description" width="378" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And it seems like &lt;br&gt;
&lt;strong&gt;res.clearCookie("jwt")&lt;/strong&gt;&lt;br&gt;
is not working here 👇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s0X7tr5G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4jyfatpo9j33bzwl5n6f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s0X7tr5G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4jyfatpo9j33bzwl5n6f.jpg" alt="Image description" width="880" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;as the &lt;strong&gt;jwt&lt;/strong&gt; cookie is not getting deleted 😑 Please help I am stuck from weeks. Unable to figure out how to make it work.&lt;/p&gt;

</description>
      <category>node</category>
      <category>codenewbie</category>
      <category>help</category>
    </item>
    <item>
      <title>Need Help!! How to submit a form and receive the form data in email like - in gmail ??</title>
      <dc:creator>dev-shubham098</dc:creator>
      <pubDate>Thu, 27 Jan 2022 21:06:17 +0000</pubDate>
      <link>https://forem.com/paradox098/need-help-how-to-submit-a-form-and-receive-the-form-data-in-email-like-in-gmail--2oeg</link>
      <guid>https://forem.com/paradox098/need-help-how-to-submit-a-form-and-receive-the-form-data-in-email-like-in-gmail--2oeg</guid>
      <description>&lt;p&gt;Hello DEV community 🖐🏼 My post here, as a newbie by following some tutorials I have created my first CRUD application using express, mongoose which sends form data to MongoDB in the localhost. &lt;/p&gt;

&lt;p&gt;But, now I want to know can the same form be used to send form data also into gmail by using nodemailer and mailgun or alternatives like mailersend.&lt;/p&gt;

&lt;p&gt;I have found this ⬇ nice tutorial which only teaches how to send form data into gmail :&lt;/p&gt;

&lt;p&gt;[&lt;a href="https://www.youtube.com/watch?v=JpcLd5UrDOQ"&gt;https://www.youtube.com/watch?v=JpcLd5UrDOQ&lt;/a&gt;]&lt;/p&gt;

</description>
      <category>node</category>
      <category>codenewbie</category>
      <category>help</category>
      <category>npm</category>
    </item>
  </channel>
</rss>
