<?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: Damish</title>
    <description>The latest articles on DEV Community by Damish (@damish).</description>
    <link>https://dev.to/damish</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%2F403741%2F300e798d-fc4e-4aa3-b149-b43b6b68a38f.png</url>
      <title>DEV Community: Damish</title>
      <link>https://dev.to/damish</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/damish"/>
    <language>en</language>
    <item>
      <title>The SQL databases vs NoSQL databases [Difference]</title>
      <dc:creator>Damish</dc:creator>
      <pubDate>Tue, 09 Jun 2020 17:51:01 +0000</pubDate>
      <link>https://dev.to/damish/the-sql-databases-vs-nosql-databases-difference-5b1n</link>
      <guid>https://dev.to/damish/the-sql-databases-vs-nosql-databases-difference-5b1n</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--L_2n-6mq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0ywzfd6lieud01adcx9n.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--L_2n-6mq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0ywzfd6lieud01adcx9n.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SQL databases: SQL databases use structured query language (SQL) for defining and manipulating data. On one hand, this is extremely powerful: SQL is one of the most versatile and widely-used options available, making it a safe choice and especially great for complex queries.&lt;/p&gt;

&lt;p&gt;NoSQL databases: NoSQL databases have dynamic schemas for unstructured data, and data is stored in many ways: They can be column-oriented, document-oriented, graph-based or organized as a KeyValue store. This flexibility means that,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;    You can create documents without having to first define their structure&lt;/li&gt;
&lt;li&gt;    Each document can have its own unique structure&lt;/li&gt;
&lt;li&gt;    The syntax can vary from database to database, and&lt;/li&gt;
&lt;li&gt;    You can add fields as you go.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>nosql</category>
      <category>sql</category>
      <category>mongodb</category>
      <category>database</category>
    </item>
    <item>
      <title>How to GET data from an API in React JS</title>
      <dc:creator>Damish</dc:creator>
      <pubDate>Sun, 07 Jun 2020 14:20:45 +0000</pubDate>
      <link>https://dev.to/damish/how-to-get-data-from-an-api-in-react-js-5ecc</link>
      <guid>https://dev.to/damish/how-to-get-data-from-an-api-in-react-js-5ecc</guid>
      <description>&lt;p&gt;Hello everyone today I’m going to show you how to implement HTTP GET action of any API inside a React JS application. For this, we use fetch() function.&lt;/p&gt;

&lt;p&gt;Here the input parameter passed for the fetch function is an API URL. And the response from API is a JSON type response.We can set the response data to a state variable using this.setState({ }) .Here I have used sensors array list to store the data comming from fetch() method.&lt;/p&gt;

&lt;p&gt;The structure of the fetch function is as follows,&lt;/p&gt;

&lt;p&gt;import React , {Component} from 'react';&lt;br&gt;
class App extends Component {&lt;/p&gt;

&lt;p&gt;state = {&lt;br&gt;
  loading: true,&lt;br&gt;
  sensors: null,&lt;br&gt;
};&lt;br&gt;
 componentDidMount() {&lt;br&gt;
      fetch('api.example.com')&lt;br&gt;
            .then((response) =&amp;gt; {&lt;br&gt;
                   return response.json();&lt;br&gt;
            })&lt;br&gt;
            .then((data) =&amp;gt; {&lt;br&gt;
                  this.setState({&lt;br&gt;
                        sensors: data,&lt;br&gt;
                        loading: false&lt;br&gt;
            })&lt;br&gt;
             console.log(data);&lt;br&gt;
       });&lt;br&gt;
   }&lt;/p&gt;

&lt;p&gt;Let us come to the rendering part of the component in index.html,&lt;/p&gt;

&lt;p&gt;Here we can add a loading screen using another Boolean state variable (this.state.loading) which is displayed until data is been fetched from the API as follows,&lt;/p&gt;

&lt;p&gt;*Note: Here I have used bootstrap 4 for the project.If you don’t use bootstrap css, remove &amp;lt;&amp;lt; className={“”} &amp;gt;&amp;gt; attributes in &lt;/p&gt; tags or Instead use only pure  tags and test.

&lt;p&gt;render() {&lt;br&gt;
 if (this.state.loading) {  //this content is displayed when (loading == true) &lt;br&gt;
 return (&lt;br&gt;
            &lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;            &amp;lt;div className={"row mt-4 justify-content-center"}&amp;gt;
                &amp;lt;div className="spinner-border" role="status"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;/div&amp;gt;


            &amp;lt;div className={"row mt-4 justify-content-center"}&amp;gt;
                &amp;lt;h1&amp;gt;Fetching data...please wait&amp;lt;/h1&amp;gt;
            &amp;lt;/div&amp;gt;


        &amp;lt;/div&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;return (&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{this.state.sensors.map((value) =&amp;amp;gt; {


    return (

               &amp;lt;h5&amp;gt;Sid: {value.sid} &amp;lt;/h5&amp;gt;
               &amp;lt;h4&amp;gt;Co2 Level: {value.co2Level}&amp;lt;/h4&amp;gt;

               &amp;lt;h4&amp;gt;Smoke Level: {value.smokeLevel}&amp;lt;/h4&amp;gt;
               &amp;lt;h5&amp;gt;Floor No: {value.floorNo}&amp;lt;/h5&amp;gt;
               &amp;lt;h5&amp;gt;Room No: {value.roomNo}&amp;lt;/h5&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;)&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;I hope now you are clear about the fetch function and its implementation. If you have any questions please comment below. Stay connected with our blog for more posts like this.&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%2Fi%2F0uwy7t7p55vcz0obfbeg.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%2Fi%2F0uwy7t7p55vcz0obfbeg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>restapi</category>
    </item>
  </channel>
</rss>
