<?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>DEV Community: Simone Aronica</title>
    <description>The latest articles on DEV Community by Simone Aronica (@itssimondev).</description>
    <link>https://dev.to/itssimondev</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%2F221247%2F36b20955-4a12-44d6-9555-f10979e7694c.jpg</url>
      <title>DEV Community: Simone Aronica</title>
      <link>https://dev.to/itssimondev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/itssimondev"/>
    <language>en</language>
    <item>
      <title>C++ read file from stdin</title>
      <dc:creator>Simone Aronica</dc:creator>
      <pubDate>Sat, 08 Feb 2020 10:28:16 +0000</pubDate>
      <link>https://dev.to/itssimondev/c-read-file-from-stdin-35pn</link>
      <guid>https://dev.to/itssimondev/c-read-file-from-stdin-35pn</guid>
      <description>&lt;p&gt;I've started to learn c++ and I need a way to read a file line by line directly from stdin. Now what I've tried is this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;freopen("input.txt", "r", stdin);
string buffer;
vector&amp;lt;int&amp;gt; temp = {};
getline(cin, buffer);
for(int elem : buffer) 
  if(elem != ' ')
    temp.push_back(elem - '0');
*dest = temp;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;but when I run this code, the console waits for me to insert data via cli instead of reading it from stdin.&lt;br&gt;
What can I do?&lt;/p&gt;

</description>
      <category>help</category>
    </item>
    <item>
      <title>Fetch returns an array, but javascript doesn't recognise fields.</title>
      <dc:creator>Simone Aronica</dc:creator>
      <pubDate>Thu, 06 Feb 2020 10:28:22 +0000</pubDate>
      <link>https://dev.to/itssimondev/fetch-returns-an-array-but-javascript-doesn-t-recognise-fields-ie7</link>
      <guid>https://dev.to/itssimondev/fetch-returns-an-array-but-javascript-doesn-t-recognise-fields-ie7</guid>
      <description>&lt;h1&gt;
  
  
  Background
&lt;/h1&gt;

&lt;p&gt;I'm creating a website for my school using react and node.js. Now when I fetch all the articles the fetch actually sends all the articles, but javascript doesn't the whole data.&lt;/p&gt;

&lt;p&gt;This is what the network receives:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgmq69lw3v6pm7rayt4ga.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgmq69lw3v6pm7rayt4ga.png" alt="Network page" width="161" height="81"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp4myeej5a0s32alluctu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp4myeej5a0s32alluctu.png" alt="Console.log" width="161" height="81"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch(`/api/article/fetchlatest?offset=${offset}`)
      .then(res =&amp;gt; res.json())
      .then(res =&amp;gt; {
        console.log(res); // this is the console.log stated before
        setList(res);
        setFetched(true);
        setOffset(offset + 10);
      });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>help</category>
    </item>
    <item>
      <title>Editor.js react viewer</title>
      <dc:creator>Simone Aronica</dc:creator>
      <pubDate>Sat, 18 Jan 2020 14:59:38 +0000</pubDate>
      <link>https://dev.to/itssimondev/editor-js-viewer-5ama</link>
      <guid>https://dev.to/itssimondev/editor-js-viewer-5ama</guid>
      <description>&lt;p&gt;I've been using editor.js and react-editor-js as a WYSIWYG editor and now that I've developed the backend for images and text storing in a mongo database, I'm facing another issue: viewing those articles.&lt;/p&gt;

&lt;p&gt;For those of you who don't know this is how every paragraph gets stored in editor.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"{\"time\":1579259743447,\"blocks\":[{\"type\":\"paragraph\",\"data\":{\"text\":\"How can I resist you?\"}},{\"type\":\"list\",\"data\":{\"style\":\"ordered\",\"items\":[\"&amp;lt;b&amp;gt;Mammamia&amp;lt;/b&amp;gt;\"]}},{\"type\":\"paragraph\",\"data\":{\"text\":\"1&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;Bebebe&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;\"}},{\"type\":\"paragraph\",\"data\":{\"text\":\"&amp;lt;a href=\\\"https://google.com/\\\"&amp;gt;Bobobo&amp;lt;/a&amp;gt;\"}},{\"type\":\"quote\",\"data\":{\"text\":\"Pull me\",\"caption\":\"\",\"alignment\":\"left\"}},{\"type\":\"header\",\"data\":{\"text\":\"Mamma\",\"level\":1}},{\"type\":\"paragraph\",\"data\":{\"text\":\"1wowowo\"}},{\"type\":\"list\",\"data\":{\"style\":\"ordered\",\"items\":[\"Bismillah\"]}},{\"type\":\"paragraph\",\"data\":{\"text\":\"We will not let you go\"}},{\"type\":\"paragraph\",\"data\":{\"text\":\"Bis\"}},{\"type\":\"list\",\"data\":{\"style\":\"ordered\",\"items\":[\"Bismillah\"]}}],\"version\":\"2.16.1\"}"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;And my issue now is trying to show those &lt;code&gt;&amp;lt;a&amp;gt; &amp;lt;i&amp;gt; &amp;lt;b&amp;gt;&lt;/code&gt; as I can't just paste them into react like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p&amp;gt;{elem.data.text}&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;because react will reder &lt;b&gt;, &lt;i&gt; and &lt;a&gt; as a text instead of as elements.&lt;br&gt;
What can I do to overcome this issue?&lt;/a&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;This is what I've done so far:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;section&amp;gt;
        {article.body != undefined
          ? JSON.parse(article.body).blocks.map(elem =&amp;gt; {
              console.log(elem);
              let rElem;
              switch (elem.type) {
                case "paragraph":
                  rElem = &amp;lt;p&amp;gt;{elem.data.text}&amp;lt;/p&amp;gt;;
                  break;
                case "list":
                  switch (elem.data.style) {
                    case "ordered":
                      rElem = (
                        &amp;lt;ol&amp;gt;
                          {elem.data.items.map(innerElem =&amp;gt; {
                            return &amp;lt;li&amp;gt;{innerElem.text}&amp;lt;/li&amp;gt;;
                          })}
                        &amp;lt;/ol&amp;gt;
                      );
                      break;
                    case "unordered":
                      rElem = (
                        &amp;lt;ul&amp;gt;
                          {elem.data.items.map(innerElem =&amp;gt; {
                            return &amp;lt;li&amp;gt;{innerElem.text}&amp;lt;/li&amp;gt;;
                          })}
                        &amp;lt;/ul&amp;gt;
                      );
                      break;
                  }
                  break;
                case "image":
                  rElem = (
                    &amp;lt;img
                      src={elem.data.file.url}
                      width={elem.data.file.width}
                      height={elem.data.file.height}
                      alt={elem.data.file.url}
                    /&amp;gt;
                  );
                  break;
                case "header":
                  switch (elem.data.level) {
                    case 1:
                      rElem = &amp;lt;h1&amp;gt;{elem.data.text}&amp;lt;/h1&amp;gt;;
                      break;
                    case 2:
                      rElem = &amp;lt;h2&amp;gt;{elem.data.text}&amp;lt;/h2&amp;gt;;
                      break;
                    case 3:
                      rElem = &amp;lt;h3&amp;gt;{elem.data.text}&amp;lt;/h3&amp;gt;;
                      break;
                    case 4:
                      rElem = &amp;lt;h4&amp;gt;{elem.data.text}&amp;lt;/h4&amp;gt;;
                      break;
                    case 5:
                      rElem = &amp;lt;h5&amp;gt;{elem.data.text}&amp;lt;/h5&amp;gt;;
                      break;
                    case 6:
                      rElem = &amp;lt;h6&amp;gt;{elem.data.text}&amp;lt;/h6&amp;gt;
                      break;
                  }
                  break;
                default:
                  rElem = null;
              }
              return rElem;
            })
          : null}
      &amp;lt;/section&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>help</category>
    </item>
    <item>
      <title>Should a new webapp run on both http and https protocols?</title>
      <dc:creator>Simone Aronica</dc:creator>
      <pubDate>Sun, 29 Dec 2019 23:38:30 +0000</pubDate>
      <link>https://dev.to/itssimondev/should-a-new-webapp-run-on-both-http-and-https-protocols-56ao</link>
      <guid>https://dev.to/itssimondev/should-a-new-webapp-run-on-both-http-and-https-protocols-56ao</guid>
      <description>&lt;p&gt;I've been thinking about how to host my webapp and as I use a react frontend with serious authentication protocols, should my app be based on both http and https or use only https? More and more time thinking is leading me towards the latter, but I'm not sure. What do you think?&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>[SOLVED] Node.js ERR_SSL_VERSION_OR_CIPHER_MISMATCH</title>
      <dc:creator>Simone Aronica</dc:creator>
      <pubDate>Fri, 27 Dec 2019 12:39:26 +0000</pubDate>
      <link>https://dev.to/itssimondev/node-js-errsslversionorciphermismatch-58o7</link>
      <guid>https://dev.to/itssimondev/node-js-errsslversionorciphermismatch-58o7</guid>
      <description>&lt;p&gt;Hello everyone,&lt;br&gt;
I am using Node.js to host a webserver with both http and https, and I have generated my self signed certificate via the openssl commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ openssl genrsa -des3 -out rootCA.key 2048
$ openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.crt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;However when I try to connect to &lt;a href="https://127.0.0.1:8080"&gt;https://127.0.0.1:8080&lt;/a&gt; or &lt;a href="https://localhost:8080"&gt;https://localhost:8080&lt;/a&gt; or the machine's IP from another device I always get ERR_SSL_VERSION_OR_CIPHER_MISMATCH&lt;/p&gt;

&lt;p&gt;What could it be? I have been trying to figure out for a while now and I can't understand what is the issue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Server code
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.env

PASSPHRASE=dummyPass
HTTPS=true
HTTPPORT=8079
HTTPSPORT=8080
KEY=rootCA.key
CERT=rootCA.crt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server.js

const httpsEnabled = process.env.HTTPS == 'true' || false;
if(httpsEnabled)
{
  const httpsPort = process.env.HTTPSPORT || 8081;
  const httpsServer = https.createServer(credentials, app);

  const keyStream = path.resolve(`./${process.env.KEY}`);
  const certificateStream = path.resolve(`./${process.env.CERT}`);
  const privateKey  = fs.readFileSync(keyStream, 'utf8');
  const certificate = fs.readFileSync(certificateStream, 'utf8');

  const credentials = {key: privateKey, cert: certificate, passphrase: process.env.PASSPHRASE};

  httpsServer.on("error", () =&amp;gt; {
    console.log(`Could not start the app on port ${httpsPort}`);
    process.exit();
  });
  httpsServer.listen(httpsPort, () =&amp;gt; {
    console.log(`App listening for HTTPS requests to https://127.0.0.1:${httpsPort}/`);
  });
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Solved:
&lt;/h2&gt;

&lt;p&gt;I'm stupid, I started the server before reading the credential. This is the fixed code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server.js

const httpsEnabled = process.env.HTTPS == "true" || false;
if (httpsEnabled) {
  const keyStream = path.resolve(`./${process.env.KEY}`);
  const certificateStream = path.resolve(`./${process.env.CERT}`);
  const privateKey = fs.readFileSync(keyStream, "utf8");
  const certificate = fs.readFileSync(certificateStream, "utf8");
  const credentials = {
    key: privateKey,
    cert: certificate,
    passphrase: process.env.PASSPHRASE
  };

  const httpsPort = process.env.HTTPSPORT || 8081;
  const httpsServer = https.createServer(credentials, app);

  httpsServer.on("error", () =&amp;gt; {
    console.log(`Could not start the app on port ${httpsPort}`);
    process.exit();
  });
  httpsServer.listen(httpsPort, () =&amp;gt; {
    console.log(
      `App listening for HTTPS requests to https://127.0.0.1:${httpsPort}/`
    );
  });
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>help</category>
    </item>
    <item>
      <title>How do I get a subcomponent value while referring to the main component?</title>
      <dc:creator>Simone Aronica</dc:creator>
      <pubDate>Wed, 18 Dec 2019 08:48:41 +0000</pubDate>
      <link>https://dev.to/itssimondev/how-do-i-get-a-subcomponent-value-while-referring-to-the-main-component-15dp</link>
      <guid>https://dev.to/itssimondev/how-do-i-get-a-subcomponent-value-while-referring-to-the-main-component-15dp</guid>
      <description>&lt;p&gt;So I have a component containing an input, and I need to access the value of this input through the main component like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//component declaration:
&amp;lt;MDTextField label='Password' type='password' ref='passwordField'/&amp;gt;

//reffing:
this.refs.passwordField
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Can I do this in the first place? And if I can, how do I do this?&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const MDTextField = props =&amp;gt; {
    PropTypes.checkPropTypes(MDTextField.propTypes, props, 'prop', 'MDTextField');
    const [isFocused, setFocused] = useState(false);
    const [isEmpty, setEmpty] = useState(true);
    const error = props.error;
    const type = props.type.toLowerCase();
    if(!type.match(/^(email|text|password|search)$/))
        throw "Invalid type. Type must be either email, text, password or search."
    console.log('error: ' + error + 'focus: ' + isFocused);
    const _setFocus = () =&amp;gt; {
        setFocused(true);
    };
    const _setUnfocus = () =&amp;gt; {
        setFocused(false);
    };
    const _handleChange = e =&amp;gt; {
        setEmpty(e.target.value.length &amp;gt; 0 ? false : true);
    };
    return (
        &amp;lt;div
        {...props}
        style={{borderColor: props.error ? "rgb(176, 0, 32)" : props.color &amp;amp;&amp;amp; isFocused ? props.color : ""}}
        className={`${props.outlined ? style.MDTextFieldOutlined : style.MDTextField} ${props.outlined ? palette.MDTextFieldOutlined : palette.MDTextField} ${props.className ? props.className : ''}`}
        onFocus={_setFocus}
        onBlur={_setUnfocus}
        &amp;gt;
        &amp;lt;label
            className={`${style.Label} ${palette.Label}`}
            style={{
            color: error ? "rgb(176, 0, 32)" : props.accentColor &amp;amp;&amp;amp; isFocused ? props.accentColor : "",
            transform: isEmpty ? "" : `translateY(-${props.outlined ? "50" : "50"}%) scale(.75)`
            }}
        &amp;gt;
            {(props.label ? props.label : '') + (error ? "*" : "")}
        &amp;lt;/label&amp;gt;
        &amp;lt;span className={style.InputWrapper}&amp;gt;
            &amp;lt;input
            style={{caretColor: error ? "rgb(176, 0, 32)" : (props.accentColor ? props.accentColor : "")}}
            className={`${style.TextInput} ${palette.TextInput}`}
            onChange={_handleChange}
            type={type}
            /&amp;gt;
        &amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
    );
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>help</category>
    </item>
    <item>
      <title>Usestate hook not working inside arrow component.</title>
      <dc:creator>Simone Aronica</dc:creator>
      <pubDate>Tue, 17 Dec 2019 12:08:36 +0000</pubDate>
      <link>https://dev.to/itssimondev/usestate-hook-not-working-inside-arrow-component-44kh</link>
      <guid>https://dev.to/itssimondev/usestate-hook-not-working-inside-arrow-component-44kh</guid>
      <description>&lt;h2&gt;
  
  
  The story
&lt;/h2&gt;

&lt;p&gt;So I'm trying to replicate a Material Design text field, and I think I've managed to do that pretty well, as in this Code Sandbox: &lt;a href="https://1d053.csb.app/"&gt;https://1d053.csb.app/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now the only difference between this sandbox and the component I'll show later on is the use of scss modules instead of pure scss.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;When I test this component it results in an Invalid Hook Call.&lt;br&gt;
This is the error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main.js:170 Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
    at resolveDispatcher (react.development.js:1590)
    at useState (react.development.js:1618)
    at MDTextField (index.js:25)
    at hi (main.js:170)
    at Rs (main.js:170)
    at Ol (main.js:170)
    at Pl (main.js:170)
    at wl (main.js:170)
    at yl (main.js:170)
    at ou (main.js:170)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now to my knowledge I see no reason for it to result in an invalid hook call.&lt;/p&gt;

&lt;h2&gt;
  
  
  The code
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;textfield/index.js

const MDTextField = props =&amp;gt; {
    const [isFocused, setFocused] = useState(false);
    const [isEmpty, setEmpty] = useState(true);
    const _setFocus = () =&amp;gt; {
        setFocused(true);
    };
    const _setUnfocus = () =&amp;gt; {
        setFocused(false);
    };
    const _handleChange = e =&amp;gt; {
        setEmpty(e.target.value.length &amp;gt; 0 ? false : true);
    };
    return (
        &amp;lt;div
        style={{
            borderColor: props.error
            ? "rgb(176, 0, 32)"
            : props.color &amp;amp;&amp;amp; isFocused
            ? props.color
            : ""
        }}
        className={`${props.outlined ? style.MDTextFieldOutlined : style.MDTextField} ${palette.MDTextField} ${props.className ? props.className : ''}`}
        onFocus={_setFocus}
        onBlur={_setUnfocus}
        &amp;gt;
        &amp;lt;span
            className={`${style.Label} ${palette.Label}`}
            style={{
            color: props.error
                ? "rgb(176, 0, 32)"
                : props.color &amp;amp;&amp;amp; isFocused
                ? props.color
                : "",
            transform: isEmpty
                ? ""
                : `translateY(-${props.outlined ? "50" : "50"}%) scale(.75)`
            }}
        &amp;gt;
            {props.label + (props.error ? "*" : "")}
        &amp;lt;/span&amp;gt;
        &amp;lt;span className={style.InputWrapper}&amp;gt;
            &amp;lt;input
            style={{
                caretColor: props.error
                ? "rgb(176, 0, 32)"
                : props.color
                ? props.color
                : ""
            }}
            className={`${style.TextInput} ${palette.TextInput}`}
            onChange={_handleChange}
            /&amp;gt;
        &amp;lt;/span&amp;gt;
        &amp;lt;/div&amp;gt;
    );
};

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



&lt;h2&gt;
  
  
  Also
&lt;/h2&gt;

&lt;p&gt;Thank you for taking the time to read this issue, and I hope to find someone able enough to understand this error.&lt;/p&gt;

&lt;h2&gt;
  
  
  Edits:
&lt;/h2&gt;

&lt;p&gt;This is the code I use to call the component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const App = () =&amp;gt; {
    const style = useStyles();
    return &amp;lt;&amp;gt;
        &amp;lt;div className={style.bg}&amp;gt;
            &amp;lt;MDCard media='https://images7.alphacoders.com/909/909467.jpg' &amp;gt;
                &amp;lt;MDCardTitle&amp;gt;Title goes here&amp;lt;/MDCardTitle&amp;gt;
                &amp;lt;MDCardSubtitle&amp;gt;Secondary text&amp;lt;/MDCardSubtitle&amp;gt;
                &amp;lt;MDCardSection&amp;gt;Greyhound divisively hello coldly wonderfully marginally far upon excluding.&amp;lt;/MDCardSection&amp;gt;
                &amp;lt;MDCardSection&amp;gt;Tags: &amp;lt;b&amp;gt;#reactjs&amp;lt;/b&amp;gt;&amp;lt;/MDCardSection&amp;gt;
                &amp;lt;MDDivider /&amp;gt;
                &amp;lt;MDButton text&amp;gt;button&amp;lt;/MDButton&amp;gt;
                &amp;lt;MDButton text&amp;gt;button&amp;lt;/MDButton&amp;gt;
            &amp;lt;/MDCard&amp;gt;
            &amp;lt;MDCard media='https://images7.alphacoders.com/909/909467.jpg' dark&amp;gt;
                &amp;lt;MDCardTitle&amp;gt;Title goes here&amp;lt;/MDCardTitle&amp;gt;
                &amp;lt;MDCardSubtitle&amp;gt;Secondary text&amp;lt;/MDCardSubtitle&amp;gt;
                &amp;lt;MDCardSection&amp;gt;Greyhound divisively hello coldly wonderfully marginally far upon excluding.&amp;lt;/MDCardSection&amp;gt;
            &amp;lt;/MDCard&amp;gt;
            &amp;lt;MDCard&amp;gt;
                &amp;lt;MDCardTitle&amp;gt;Title goes here&amp;lt;/MDCardTitle&amp;gt;
                &amp;lt;MDCardSubtitle&amp;gt;Secondary text&amp;lt;/MDCardSubtitle&amp;gt;
                &amp;lt;MDButton text&amp;gt;Button&amp;lt;/MDButton&amp;gt;
            &amp;lt;/MDCard&amp;gt;
            &amp;lt;MDCard dark&amp;gt;
                &amp;lt;MDCardTitle&amp;gt;Title goes here&amp;lt;/MDCardTitle&amp;gt;
                &amp;lt;MDCardSubtitle&amp;gt;Secondary text&amp;lt;/MDCardSubtitle&amp;gt;
                &amp;lt;MDButton accentColor='#1da3dc' text&amp;gt;button&amp;lt;/MDButton&amp;gt;
            &amp;lt;/MDCard&amp;gt;
            &amp;lt;div className={style.bw}&amp;gt;
                &amp;lt;MDButton&amp;gt;Button&amp;lt;/MDButton&amp;gt;
                &amp;lt;MDButton outlined&amp;gt;Button&amp;lt;/MDButton&amp;gt;
                &amp;lt;MDButton text&amp;gt;Button&amp;lt;/MDButton&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div className={style.bw}&amp;gt;
                &amp;lt;MDButton accentColor='#212121'&amp;gt;Button&amp;lt;/MDButton&amp;gt;
                &amp;lt;MDButton outlined accentColor='#212121'&amp;gt;Button&amp;lt;/MDButton&amp;gt;
                &amp;lt;MDButton text accentColor='#212121'&amp;gt;Button&amp;lt;/MDButton&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div className={style.br}&amp;gt;
                &amp;lt;MDFloatingButton &amp;gt;+&amp;lt;/MDFloatingButton&amp;gt;
                &amp;lt;MDFloatingButton mini&amp;gt;+&amp;lt;/MDFloatingButton&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;div className={style.bw}&amp;gt;
                &amp;lt;MDTextField /&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Every other component is fine since if I remove this component, everything else works.&lt;/p&gt;

</description>
      <category>help</category>
    </item>
    <item>
      <title>Handling async await</title>
      <dc:creator>Simone Aronica</dc:creator>
      <pubDate>Mon, 09 Dec 2019 22:58:07 +0000</pubDate>
      <link>https://dev.to/itssimondev/handling-async-await-17d</link>
      <guid>https://dev.to/itssimondev/handling-async-await-17d</guid>
      <description>&lt;p&gt;I'm trying to implement a register system, and I have to validate the mail and check that it's not already being used by another account in the database. The problem is that the validator function for email must be asynchronous as the query is asynchronous, but the verifyUser function that among other things verifies the email must be a normal function.&lt;/p&gt;

&lt;h2&gt;
  
  
  To the code!
&lt;/h2&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function _verifyEmail(User){
    const { email } = User;
    var isAvailable = await UserModel.countDocuments({email: email}).then(res =&amp;gt; isAvailable = res &amp;gt; 0 ? false : true);
    var isValid = EmailValidator.validate(email)
    console.log(`isValid: ${isValid}`)
    console.log(`isAvailable: ${isAvailable}`);
    if(!!isValid || !isAvailable)
        return 400;
    else
        return 202;   
}

function _verifyUser(User){
    var emailStatus;
    _verifyEmail(User).then(res =&amp;gt; {
        emailStatus = res;
        console.log(`res: ${res}`);
    });

    const passwordStatus = _verifyPassword(User);
    const nameStatus = _verifyName(User);
    const surnameStatus = _verifySurname(User);

    console.log(`email status: ${emailStatus}`);
    console.log(`password status: ${passwordStatus}`);
    console.log(`name status: ${nameStatus}`);
    console.log(`surname status: ${surnameStatus}`);

    if(emailStatus === 400 || passwordStatus === 400 || nameStatus === 400 || surnameStatus === 400)
        return 400;
    else
        return 202;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;When I run this code while every other parameter in _verifyUser is fine, emailStatus is unavailable since the _verifyEmail function returns after the if  computation. &lt;/p&gt;

&lt;p&gt;How can I solve this?&lt;/p&gt;

</description>
      <category>help</category>
    </item>
    <item>
      <title>ReadFileSync return ENOENT</title>
      <dc:creator>Simone Aronica</dc:creator>
      <pubDate>Sun, 08 Dec 2019 10:49:06 +0000</pubDate>
      <link>https://dev.to/itssimondev/readfilesync-return-enoent-3ef3</link>
      <guid>https://dev.to/itssimondev/readfilesync-return-enoent-3ef3</guid>
      <description>&lt;h1&gt;
  
  
  A bit of backstory
&lt;/h1&gt;

&lt;p&gt;I'm trying to run an https REST server with express and I'm using webpack to compile and bundle.&lt;br&gt;
Now this is my structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-dist
-src
 -server
  server.js
 client
  index.html
  index.js
.babelrc
package.json
webpack.config.js
rootCA.key
rootCA.pem
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I have imported in server.js rootCA.key and rootCA.pem like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;7 import key from '../../rootCA.key';
8 import cert from '../../rootCA.pem';
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;so whenever I build in my dist folder I import those files through file-loader.&lt;/p&gt;

&lt;h1&gt;
  
  
  Now to the problem
&lt;/h1&gt;

&lt;p&gt;When I run the server and those two lines are executed the result is an ENOENT like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fs.js:114
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/406598dc63994ef30b45f867a314da17.key'
    at Object.openSync (fs.js:443:3)
    at Object.readFileSync (fs.js:343:35)
    at eval (webpack:///./src/server/server.js?:19:21)
    at Module../src/server/server.js (C:\Users\simon\Desktop\CodeProjects\dual-setup\dist\server.js:121:1)
    at __webpack_require__ (C:\Users\simon\Desktop\CodeProjects\dual-setup\dist\server.js:20:30)
    at C:\Users\simon\Desktop\CodeProjects\dual-setup\dist\server.js:84:18
    at Object.&amp;lt;anonymous&amp;gt; (C:\Users\simon\Desktop\CodeProjects\dual-setup\dist\server.js:87:10)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I don't understand what the problem could be as both server.js and the key are in  the dist directory.&lt;/p&gt;

&lt;h1&gt;
  
  
  Some configurations
&lt;/h1&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;webpack.config.js


const path = require('path')
const fs = require('fs');
const nodeExternals = require('webpack-node-externals')
module.exports = {
  entry: {
    server: './src/server/server.js',
  },
  output: {
    path: path.join(__dirname, 'dist'),
    publicPath: '/',
    filename: '[name].js'
  },
  target: 'node',
  node: {
    // Need this when working with express, otherwise the build fails
    __dirname: false,   // if you don't put this is, __dirname
    __filename: false,  // and __filename return blank or /
  },
  externals: [nodeExternals()], // Need this to avoid error when working with Express
  module: {
    rules: [
      {
        // Transpiles ES6-8 into ES5
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader"
        }
      },
      {
        test: /\.(pem|key)$/,
        use: {
          loader: 'file-loader'
        }
      }
    ]
  },
  devServer: {
    contentBase: path.join(__dirname, 'dist'),
    compress: true,
    port: 8080,
    https: {
      cert: fs.readFileSync('./rootCA.pem'),
      key: fs.readFileSync('./rootCA.key')
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It should be noted that the command that I use to run the server is as simple as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node ./dist/server.js
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>help</category>
    </item>
  </channel>
</rss>
