<?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: Md. Akramul Hoque</title>
    <description>The latest articles on DEV Community by Md. Akramul Hoque (@ahlikhon).</description>
    <link>https://dev.to/ahlikhon</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%2F768775%2Fc02728a5-8755-40a9-9f27-c534a79c0368.jpeg</url>
      <title>DEV Community: Md. Akramul Hoque</title>
      <link>https://dev.to/ahlikhon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ahlikhon"/>
    <language>en</language>
    <item>
      <title>Node CRUD Operations</title>
      <dc:creator>Md. Akramul Hoque</dc:creator>
      <pubDate>Thu, 23 Dec 2021 16:44:42 +0000</pubDate>
      <link>https://dev.to/ahlikhon/node-crud-operations-41k2</link>
      <guid>https://dev.to/ahlikhon/node-crud-operations-41k2</guid>
      <description>&lt;p&gt;&lt;strong&gt;CRUD&lt;/strong&gt; (create, read, update, delete) is an acronym that refers to the four functions. There are different requests for each issue. For querying, we have GET requests, for sending data we have POST requests. These are called HTTP requests. They enable interactions between client and the server and work as a request-response protocol. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KiMUygG9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rqqreyzyfpztn8az974c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KiMUygG9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rqqreyzyfpztn8az974c.png" alt="CRUD operation" width="615" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;The HTTP requests are:&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GET&lt;/strong&gt; is used to request data from a specified resource.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;POST&lt;/strong&gt; is used to send data to a server to create/update a resource.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HEAD:&lt;/strong&gt; Same as GET, but it transfers the status line and the header section only.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PUT:&lt;/strong&gt; Replaces all the current representations of the target resource with the uploaded content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DELETE:&lt;/strong&gt; Removes all the current representations of the target resource given by URI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CONNECT:&lt;/strong&gt; Establishes a tunnel to the server identified by a given URI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PATCH:&lt;/strong&gt; The PATCH method applies partial modifications to a resource&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Route definition takes the following structure:&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.METHOD(PATH, HANDLER)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Where:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;app&lt;/code&gt; is an instance of express.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;METHOD&lt;/code&gt; is an HTTP request method, in lowercase.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;PATH&lt;/code&gt; is a path on the server. (URL path)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;HANDLER&lt;/code&gt; is the function executed when the route is matched. (Handler function)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For GET method:&lt;/strong&gt;&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('/save', function(req, res) {
       // write query here
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;For POST method:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.post('/save', function(req, res) {
       // write query here
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;For PUT method:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.put('/save/:id', function(req, res) {
       // write query here
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;For DELETE method:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.delete('/save/:id', function(req, res) {
       // write query here
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>node</category>
      <category>react</category>
      <category>mongodb</category>
      <category>javascript</category>
    </item>
    <item>
      <title>React Context API</title>
      <dc:creator>Md. Akramul Hoque</dc:creator>
      <pubDate>Thu, 23 Dec 2021 15:05:06 +0000</pubDate>
      <link>https://dev.to/ahlikhon/react-context-api-2mbc</link>
      <guid>https://dev.to/ahlikhon/react-context-api-2mbc</guid>
      <description>&lt;p&gt;&lt;strong&gt;Context API&lt;/strong&gt; is a way to produce variables that can be passed around without having to pass props down manually at every level.&lt;/p&gt;

&lt;p&gt;Syntax is &lt;strong&gt;React.createConetxt(Provider, Consumer)&lt;/strong&gt;.  It returns a provider and consumer. A provider provides the state to its children. It will be the parent of all the components and store all. Consumer is a component that consumes and uses the state.&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%2Fx13h42ls44fa1mbf4cjy.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%2Fx13h42ls44fa1mbf4cjy.png" alt="React Context API"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Let’s explore how we would handle common problems without the React Context API:&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;App.js&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class App extends Component {
    state = {
        cars: {
            car01: { name: 'Honda', price: 100 },
            car02: { name: 'BMW', price: 150 },
            car03: { name: 'Mercedes', price: 200 }
        }
    };
    incrementCarPrice = this.incrementCarPrice.bind(this);
    decrementCarPrice = this.decrementCarPrice.bind(this);

    incrementCarPrice(selectedID) {
        // a simple method that manipulates the state
        const cars = Object.assign({}, this.state.cars);
        cars[selectedID].price = cars[selectedID].price + 1;
        this.setState({
            cars
        });
    }

    decrementCarPrice(selectedID) {
        // a simple method that manipulates the state
        const cars = Object.assign({}, this.state.cars);
        cars[selectedID].price = cars[selectedID].price - 1;
        this.setState({
            cars
        });
    }

    render() {
        return (
            &amp;lt;div className="App"&amp;gt;
                &amp;lt;header className="App-header"&amp;gt;
                    &amp;lt;img src={logo} className="App-logo" alt="logo" /&amp;gt;
                    &amp;lt;h1 className="App-title"&amp;gt;Welcome to my web store&amp;lt;/h1&amp;gt;
                &amp;lt;/header&amp;gt;
                {/* Pass props twice */}
                &amp;lt;ProductList
                    cars={this.state.cars}
                    incrementCarPrice={this.incrementCarPrice}
                    decrementCarPrice={this.decrementCarPrice}
                /&amp;gt;
            &amp;lt;/div&amp;gt;
        );
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;ProductList.js&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const ProductList = props =&amp;gt; (
    &amp;lt;div className="product-list"&amp;gt;
        &amp;lt;h2&amp;gt;Product list:&amp;lt;/h2&amp;gt;
        {/* Pass props twice */}
        &amp;lt;Cars
            cars={props.cars}
            incrementCarPrice={props.incrementCarPrice}
            decrementCarPrice={props.decrementCarPrice}
        /&amp;gt;
        {/* Other potential product categories which we will skip for this demo: */}
        {/* &amp;lt;Electronics /&amp;gt; */}
        {/* &amp;lt;Clothes /&amp;gt; */}
        {/* &amp;lt;Shoes /&amp;gt; */}
    &amp;lt;/div&amp;gt;
);

export default ProductList;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;Cars.js&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Cars = props =&amp;gt; (
    &amp;lt;Fragment&amp;gt;
        &amp;lt;h4&amp;gt;Cars:&amp;lt;/h4&amp;gt;
        {/* Finally we can use data */}
        {Object.keys(props.cars).map(carID =&amp;gt; (
            &amp;lt;Car
                key={carID}
                name={props.cars[carID].name}
                price={props.cars[carID].price}
                incrementPrice={() =&amp;gt; props.incrementCarPrice(carID)}
                decrementPrice={() =&amp;gt; props.decrementCarPrice(carID)}
            /&amp;gt;
        ))}
    &amp;lt;/Fragment&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;Car.js&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Cars = props =&amp;gt; (
    &amp;lt;Fragment&amp;gt;
        &amp;lt;p&amp;gt;Name: {props.name}&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;Price: ${props.price}&amp;lt;/p&amp;gt;
        &amp;lt;button onClick={props.incrementPrice}&amp;gt;&amp;amp;uarr;&amp;lt;/button&amp;gt;
        &amp;lt;button onClick={props.decrementPrice}&amp;gt;&amp;amp;darr;&amp;lt;/button&amp;gt;
    &amp;lt;/Fragment&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;Let’s explore how we would handle common problems with the React Context API:&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;1. Initialize the Context&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, we need to create the context, which we can later use to create providers and consumers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;MyContext.js&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';

const MyContext = React.createContext();

export default MyContext;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;2. Create the Provider&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once that’s done, we can import the context and use it to create our provider, which we’re calling &lt;code&gt;MyProvider&lt;/code&gt;. In it, we initialize a state with some values, which we can share via value prop our provider component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;MyProvider.js&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import MyContext from './MyContext';

class MyProvider extends Component {
    state = {
        cars: {
            car01: { name: 'Honda', price: 100 },
            car02: { name: 'BMW', price: 150 },
            car03: { name: 'Mercedes', price: 200 }
        }
    };

    render() {
        return (
            &amp;lt;MyContext.Provider
                value={{
                    cars: this.state.cars,
                    incrementPrice: selectedID =&amp;gt; {
                        const cars = Object.assign({}, this.state.cars);
                        cars[selectedID].price = cars[selectedID].price + 1;
                        this.setState({
                            cars
                        });
                    },
                    decrementPrice: selectedID =&amp;gt; {
                        const cars = Object.assign({}, this.state.cars);
                        cars[selectedID].price = cars[selectedID].price - 1;
                        this.setState({
                            cars
                        });
                    }
                }}
            &amp;gt;
                {this.props.children}
            &amp;lt;/MyContext.Provider&amp;gt;
        );
    }
}

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

&lt;/div&gt;



&lt;p&gt;To make the provider accessible to other components, we need to wrap our app with it. While we’re at it, we can get rid of the state and the methods because they are now defined in MyProvider.js.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;App.js&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class App extends Component {
    render() {
        return (
            &amp;lt;MyProvider&amp;gt;
                &amp;lt;div className="App"&amp;gt;
                    &amp;lt;header className="App-header"&amp;gt;
                        &amp;lt;img src={logo} className="App-logo" alt="logo" /&amp;gt;
                        &amp;lt;h1 className="App-title"&amp;gt;Welcome to my web store&amp;lt;/h1&amp;gt;
                    &amp;lt;/header&amp;gt;
                    &amp;lt;ProductList /&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/MyProvider&amp;gt;
        );
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;3. Create the Consumer&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We’ll need to import the context again and wrap our component with it which injects the context argument in the component. Afterward, it’s pretty straight forward. We use context, the same way we would use props. It holds all the values we’ve shared in MyProducer, we just need to use it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Cars.js&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Cars = () =&amp;gt; (
    &amp;lt;MyContext.Consumer&amp;gt;
        {context =&amp;gt; (
            &amp;lt;Fragment&amp;gt;
                &amp;lt;h4&amp;gt;Cars:&amp;lt;/h4&amp;gt;
                {Object.keys(context.cars).map(carID =&amp;gt; (
                    &amp;lt;Car
                        key={carID}
                        name={context.cars[carID].name}
                        price={context.cars[carID].price}
                        incrementPrice={() =&amp;gt; context.incrementPrice(carID)}
                        decrementPrice={() =&amp;gt; context.decrementPrice(carID)}
                    /&amp;gt;
                ))}
            &amp;lt;/Fragment&amp;gt;
        )}
    &amp;lt;/MyContext.Consumer&amp;gt;
);

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

&lt;/div&gt;



&lt;p&gt;Then we wrap the Cars.js component inside the ProductList.js component. The component is simplified because it only needs to render a few components.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const ProductList = () =&amp;gt; (
    &amp;lt;div className="product-list"&amp;gt;
        &amp;lt;h2&amp;gt;Product list:&amp;lt;/h2&amp;gt;
        &amp;lt;Cars /&amp;gt; 
    &amp;lt;/div&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;Notes:&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;1. What is the context in React?&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Ans:&lt;/code&gt;&lt;/strong&gt; React's context allows us to share information to any component, by storing it in a central place and allowing access to any component that requests it. Usually we are only able to pass data from parent to child via props.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;2. What is a provider?&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Ans:&lt;/code&gt;&lt;/strong&gt; The provider acts as a delivery service. When a consumer asks for something, it finds it in the context and delivers it to where it's needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;3. What is a consumer?&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Ans:&lt;/code&gt;&lt;/strong&gt; A consumer is where the stored information ends up. It can request data via the provider and manipulate the central store if the provider allows it.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>contextapi</category>
      <category>node</category>
      <category>react</category>
    </item>
    <item>
      <title>Javascript API Concept</title>
      <dc:creator>Md. Akramul Hoque</dc:creator>
      <pubDate>Tue, 21 Dec 2021 14:22:46 +0000</pubDate>
      <link>https://dev.to/ahlikhon/javascript-api-concept-2ccm</link>
      <guid>https://dev.to/ahlikhon/javascript-api-concept-2ccm</guid>
      <description>&lt;p&gt;&lt;code&gt;API:&lt;/code&gt; API stands for &lt;code&gt;Application Programming Interface&lt;/code&gt;. An API is a set of defined rules that explain how computers and application servers communicate with each other. API can transfer data between an application and a web server.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;REST API&lt;/code&gt; is an API that uses HTTP requests for communication with web services and must comply with certain constraints. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;CRUD and types of requests:&lt;/code&gt; CRUD contains create, read, update, and delete actions that can be performed on a data source. &lt;code&gt;In a REST API, these actions correspond to Four types of requests:&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;POST:&lt;/code&gt; Create action. Using this type of request, we can add new data to our server.&lt;br&gt;
&lt;code&gt;GET:&lt;/code&gt; Read action. This is the most common type of request. Using it, we can get the data we are interested in from those that the API is ready to share.&lt;br&gt;
&lt;code&gt;PUT:&lt;/code&gt; Update action. Changes existing information. Using this type of request, we can update/modify the value of our existing data.&lt;br&gt;
&lt;code&gt;DELETE:&lt;/code&gt; Delete action. Deletes existing information.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;**GET vs POST:**&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get method is used to show data in the frontend and the post method is used to insert/update data. &lt;/li&gt;
&lt;li&gt;In the get method, data is sent to the header and for that limited amount of data to send. On the other hand, in the post method data is sent to the body and for that large amount of data to be sent.&lt;/li&gt;
&lt;li&gt;Get is not secured and post is secured because data is exposed in the url bar or not.&lt;/li&gt;
&lt;li&gt;Get will ignore the second request until the first is required (idempotent). But post can not do it (non-idempotent).&lt;/li&gt;
&lt;li&gt;Get is more efficient than post.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In JavaScript, it was really important to know how to make HTTP requests and retrieve the dynamic data from the server. JavaScript provides some built-in browser objects and some external open source libraries to interact with the APIs.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Here are the possible ways to make an API call:&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;XMLHttpRequest&lt;/li&gt;
&lt;li&gt;fetch&lt;/li&gt;
&lt;li&gt;Axios&lt;/li&gt;
&lt;li&gt;jQuery&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Today we will discuss about Fetch and Axios:&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Fetch-&lt;/code&gt; allows us to make an HTTP request but with a straightforward interface by using promises. It’s not supported by old browsers, but very well supported among the modern ones. The fetch API is very powerful. The major disadvantage of fetch API is error handling. We can make an API call by using fetch in two ways.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;JSONPlaceholder&lt;/code&gt; is a free online REST API that we can use whenever we need some fake data.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Method 1:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch('https://jsonplaceholder.typicode.com/users')
  .then(res =&amp;gt; res.json())
  .then(users =&amp;gt; console.log(users))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Method 2(using Async and Await):&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getUsers = async() =&amp;gt; {
let res = await fetch('https://jsonplaceholder.typicode.com/users');
let data = await res.json();
console.log(data);
return data;
}

getUsers();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Axios-&lt;/code&gt; is an open-source library for making HTTP requests and provides many great features, and it works both in browsers and Node.js. It is a promise-based HTTP client that can be used in plain JavaScript and advanced frameworks like React, Vue.js, and Angular.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;We can install axios package to using these command:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install axios
or
yarn add axios
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Then, include it in HTML file like this:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script src="./node_modules/axios/dist/axios.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Or, the easiest way to include Axios is by using external CDN:&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script src="https://unpkg.com/axios/dist/axios.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s open our index.js file and create a function that will print some user information in the console by using Axios.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const getUsers = () =&amp;gt; {
 axios.get('https://reqres.in/api/users')
 .then(res =&amp;gt; {
  const users = res.data;
  console.log(‘GET users’, users);
})
 .catch(error =&amp;gt; console.error(error));
};
getUsers();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;The advantages of Axios-&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Axios performs automatic transformations and returns the data in JSON format.&lt;/li&gt;
&lt;li&gt;Better error handling&lt;/li&gt;
&lt;li&gt;Axios has a wide range of supported browsers.&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>Javascript String Method Concepts</title>
      <dc:creator>Md. Akramul Hoque</dc:creator>
      <pubDate>Mon, 20 Dec 2021 14:14:11 +0000</pubDate>
      <link>https://dev.to/ahlikhon/javascript-string-method-concepts-1pje</link>
      <guid>https://dev.to/ahlikhon/javascript-string-method-concepts-1pje</guid>
      <description>&lt;p&gt;&lt;strong&gt;String charAt(position) Method:-&lt;/strong&gt; The &lt;code&gt;charAt()&lt;/code&gt; method accepts the index of specified position and returns the character of this specified position in a string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example: 
let a = "This is a string chatAt() method";
let char = a.charAt(0);
console.log(char);

Output: T
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;String charCodeAt(position) Method:-&lt;/strong&gt; The &lt;code&gt;charCodeAt()&lt;/code&gt; method accepts the index of specified position and returns a number indicating the Unicode value of the character at the given position in a string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example: 
let a = "This is a string chatAt() method";
let char = a.charCodeAt(0);
console.log(char);

Output: 84
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;String concat([string,,]) Method:-&lt;/strong&gt; The &lt;code&gt;concat()&lt;/code&gt; joins two or more strings and returns a new string. This method can be used instead of the plus operator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example:
let a = "Javascript";
let b = "String Concept";
let c = a.concat(" ", b);
console.log(c);

Output: Javascript String Concept
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;String includes() Method:-&lt;/strong&gt; The &lt;code&gt;includes()&lt;/code&gt; method accepts a string and its position and then returns true if a string contains a specified string, Otherwise it returns false. The includes() method is case sensitive. Its syntax is like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;string.includes(searchvalue, start)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example:
let a = "This is a text string";
let result1 = a.includes("tex", 10);
let result2= a.includes("tex", 5);
console.log(result1);
console.log(result2);

Output: 
True
False

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;String lastIndexOf() Method:-&lt;/strong&gt; The &lt;code&gt;lastIndexOf()&lt;/code&gt; method accepts a specified string and searches the string from the end to the beginning position. It returns the index from the beginning of this string, otherwise returns -1 if the value is not found. It is also case sensitive. Its syntax is like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;string.lastIndexOf(searchvalue, start)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example:
let a = "This is a text string";
let result1 = a.lastIndexOf("text");
let result2= a.lastIndexOf("Text");
console.log(result1);
console.log(result2);

Output: 
10
-1

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;String replace() Method:-&lt;/strong&gt; The &lt;code&gt;replace()&lt;/code&gt; method accepts two specified strings and Search specific string value and replace with specified replace Value string and return new string. Regular expressions can also be used as searchValue. Its syntax is like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;string.replace(searchValue, replaceValue)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example:
let a = "Please visit my portfolio";
let result= a.replace("portfolio", "website");
console.log(result);

Output: 
Please visit my website
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;String slice() Method:-&lt;/strong&gt; The &lt;code&gt;slice()&lt;/code&gt; method accepts two indexes as parameters and extracts a section of a string based on specified starting and ending index and returns a new string. Its syntax is like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;string.slice(startIndex, endIndex)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Example:
let a = "Please visit my portfolio";
let result= a.slice(7,26);
console.log(result);

Output: 
visit my portfolio
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Some CSS Important Topics</title>
      <dc:creator>Md. Akramul Hoque</dc:creator>
      <pubDate>Sun, 19 Dec 2021 15:07:01 +0000</pubDate>
      <link>https://dev.to/ahlikhon/some-css-important-topics-2hk2</link>
      <guid>https://dev.to/ahlikhon/some-css-important-topics-2hk2</guid>
      <description>&lt;p&gt;&lt;strong&gt;Flexbox Layout:&lt;/strong&gt; The flexbox layout is also known as Flexible Box Layout Module in CSS3. It allows us to design a flexible responsive layout without using any float or positioning property. It can improve the item's alignment, direction and order in a container. The flexbox layout can modify the width or height of it’s children.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flexbox  layout vs Grid layout:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flexbox  layout&lt;/strong&gt; is a one dimensional system that means it can handle only a column or a row.&lt;br&gt;
&lt;strong&gt;Grid layout&lt;/strong&gt; is a two dimensional system which can handle both columns and rows at the same time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CSS Position Property:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Static&lt;/strong&gt;- is the default position of the element which flows into the page as a normal element. The top, right, bottom, left and z-index properties do not apply.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Relative:&lt;/strong&gt;- position is adjusted to itself without changing the layout. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Absolute:&lt;/strong&gt;- is a specified position where an element is removed from the flow of the page. Using absolute positioning we can place an element exactly where we want relative to its parent. If it has no parent, then it treats the document body as its parent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fixed:&lt;/strong&gt;- is a specified position where an element is removed from the flow of the page. Using fixed positioning we can place an element where we want relative to the viewport position. These elements don't move when scroll.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sticky:&lt;/strong&gt;- is the combination of relative and fixed position. The element behaves as relative position to a certain distance, after passing this certain distance the element behaves as fixed position.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Box Model:&lt;/strong&gt; A rectangle box is wrapped around every HTML element. The CSS box model is used to determine the height and width of the rectangular box. The different elements of a box model are content, padding, border and margin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pseudo Element:&lt;/strong&gt;- Pseudo element is a feature of CSS which is used to style the given parts of an element.It is used to create items that do not normally exist in the document tree. Some pseudo elements:- ::after, ::before, ::first-letter, ::first-line, ::selection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pseudo Class:&lt;/strong&gt;- Pseudo class is a class that is used to define a special state of an HTML element. It selects regular elements but under certain conditions like when the user is hovering/focusing over the link. Some pseudo classes:- :link, :visited, :hover, :active, :focus.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transition Property:&lt;/strong&gt;- The transition property in CSS is used to make some transition effect. Its effect can be defined in two states using pseudo-classes like : hover or: active. Its syntax like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**transition:** transition-property transition-duration transition-timing-function transition-delay;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The transition is the combination of four properties which are listed below:&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;transition-property: It specifies the CSS properties to which a transition effect should be applied.&lt;/li&gt;
&lt;li&gt;transition-duration: It specifies the length of time a transition animation should take to complete.&lt;/li&gt;
&lt;li&gt;transition-timing-function: It specifies the speed of transition.&lt;/li&gt;
&lt;li&gt;transition-delay: It specifies the transition delay or time when transition starts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Transform Property:&lt;/strong&gt;- The transform property in CSS is used to change the coordinate space of the visual formatting model. This is used to add effects like skew, rotate, translate, etc on elements. The transformations can be of 2-D or 3-D type. Its syntax like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;transform: none|transform-functions|initial|inherit;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Media Query:&lt;/strong&gt;- Media query is a CSS technique introduced in CSS3.It uses the @media rule to include a block of CSS properties only if a certain condition is true. We can write media queries like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;‘declaration’  only ‘media type’ and (‘specifying amount of screen to cover’) {&lt;br&gt;
  ‘element/class’ {&lt;br&gt;
   // styles to apply when all all conditions are met&lt;br&gt;
  }&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Example:**  If the screen size is 600px wide or less, hide the element for container class.
`@media only screen and (max-width: 600px) {
  .container {
    display: none;
  }
}`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Font Size Responsive:&lt;/strong&gt;-  We can make font size responsive by using media query. If the screen size is 901px wide or more, set the font-size of the container class to 40px and  the screen size is 900px wide or less, set the font-size of &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; to 20px.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media screen and (min-width: 901px) {
  .container {
    font-size: 40px;
  }
}

@media screen and (max-width: 600px) {
  .container{
    font-size: 20px;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Overrule Underlining Hyperlinks:&lt;/strong&gt;-  Control statements and external style sheets are used to overrule underlining Hyperlinks.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Example:**
 p {
text-decoration: none;
}

&amp;lt;p href="about.html" style="text-decoration: none"&amp;gt;link text&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Box-Shadow:&lt;/strong&gt;- The box-shadow CSS property adds shadow effects around an element’s frame. We can set multiple effects separated by commas. Below are a few implementations of box-shadow&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**box-shadow:** 5px 15px 5px green;
**box-shadow:** 60px -16px teal;
**box-shadow:** 12px 12px 2px 1px rgba(0, 0, 255, .2);
            box-shadow: inset 5em 1em black;

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

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
