<?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: Mare</title>
    <description>The latest articles on Forem by Mare (@mare).</description>
    <link>https://forem.com/mare</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%2F925511%2F58aa8ac9-fb7e-465d-93b1-e0c4e3b1bd97.png</url>
      <title>Forem: Mare</title>
      <link>https://forem.com/mare</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mare"/>
    <language>en</language>
    <item>
      <title>How can i implement an guest session without authentication in a React/ExpressJS app ?</title>
      <dc:creator>Mare</dc:creator>
      <pubDate>Fri, 28 Apr 2023 11:17:04 +0000</pubDate>
      <link>https://forem.com/mare/how-can-i-implement-an-guest-session-without-authentication-in-a-reactexpressjs-app--4kl0</link>
      <guid>https://forem.com/mare/how-can-i-implement-an-guest-session-without-authentication-in-a-reactexpressjs-app--4kl0</guid>
      <description>&lt;p&gt;I'm looking to implement a functionality where the user clicks on a "Continue as a guest" , the user is assigned a guest session and is redirected to the home page.&lt;br&gt;
What could be the best way to execute this ?&lt;/p&gt;

</description>
      <category>react</category>
      <category>node</category>
      <category>mongodb</category>
      <category>express</category>
    </item>
    <item>
      <title>Changing a state and updating the changes with a put request</title>
      <dc:creator>Mare</dc:creator>
      <pubDate>Thu, 26 Jan 2023 12:38:26 +0000</pubDate>
      <link>https://forem.com/mare/changing-a-state-and-updating-the-changes-with-37bj</link>
      <guid>https://forem.com/mare/changing-a-state-and-updating-the-changes-with-37bj</guid>
      <description>&lt;p&gt;Hi !&lt;/p&gt;

&lt;p&gt;I'm trying to change the state of an element in the React component, while in the same time updating the data with a put request.&lt;/p&gt;

&lt;p&gt;There's an element "Pending" in the React component, and i'm looking to change it to "Paid".&lt;/p&gt;

&lt;p&gt;Here's the 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 [invoice, setInvoice] = useState([])

const paidInvoice =  () =&amp;gt; {
    setInvoice((invoice) =&amp;gt; {
      return({
        ...invoice,
        status:'Paid'
      });
    })

axios.put('http://localhost:5000/api/invoice/update/'+id, invoice)
    .then(response =&amp;gt; console.log(response.data))
    .catch(error =&amp;gt; console.log(error))
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem is that when i call this function after a click, the state changes, but the data is not updated so when i refresh the page it's still the same as before clicking. &lt;/p&gt;

&lt;p&gt;The invoice object that i get:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--msQtrJ5y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hcfeeec9ij0grvvp36jx.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--msQtrJ5y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hcfeeec9ij0grvvp36jx.PNG" alt="Image description" width="409" height="308"&gt;&lt;/a&gt;&lt;br&gt;
(The status must be paid not pending)&lt;br&gt;
I also noticed that when i click two consecutive times to call the function, the problem resolves and the data updates correctly in the database...&lt;/p&gt;

</description>
      <category>react</category>
      <category>node</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Creating data specifically for each user in React / Node.js</title>
      <dc:creator>Mare</dc:creator>
      <pubDate>Sat, 07 Jan 2023 18:24:02 +0000</pubDate>
      <link>https://forem.com/mare/creating-data-specifically-for-each-user-in-react-nodejs-2gdm</link>
      <guid>https://forem.com/mare/creating-data-specifically-for-each-user-in-react-nodejs-2gdm</guid>
      <description>&lt;p&gt;I'm a beginner trying to create an Invoicing application. I went with React and Node/Express, and set up the authentication with Redux.&lt;/p&gt;

&lt;p&gt;I'm currently trying to figure out how can i make it so that when a user logs in, he only sees the invoices he created himself. Because each time i connect with a different user i see the same data i previously created with another user.&lt;/p&gt;

&lt;p&gt;What would be a solution in this case ? I thought about adding a foreign key of userId for each created invoice, is it a good idea ?&lt;/p&gt;

</description>
      <category>react</category>
      <category>node</category>
      <category>mongodb</category>
    </item>
  </channel>
</rss>
