<?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: Kritika Gaur</title>
    <description>The latest articles on DEV Community by Kritika Gaur (@kritikag1997).</description>
    <link>https://dev.to/kritikag1997</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%2F1160853%2Ffb432ad3-35de-489f-a90f-5d090f81de54.jpeg</url>
      <title>DEV Community: Kritika Gaur</title>
      <link>https://dev.to/kritikag1997</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kritikag1997"/>
    <language>en</language>
    <item>
      <title>Async/Await, When, Why, How, Where, Advantages/Disadvantages, and all…</title>
      <dc:creator>Kritika Gaur</dc:creator>
      <pubDate>Tue, 19 Sep 2023 04:51:17 +0000</pubDate>
      <link>https://dev.to/kritikag1997/asyncawait-when-why-how-where-advantagesdisadvantages-and-all-2c2k</link>
      <guid>https://dev.to/kritikag1997/asyncawait-when-why-how-where-advantagesdisadvantages-and-all-2c2k</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fspnullkoxxjifw4zz0xr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fspnullkoxxjifw4zz0xr.png" alt="Image description" width="402" height="125"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hello Greeting all,&lt;/p&gt;

&lt;p&gt;Here we are going to talk about Async/await. We will dive deep into it.&lt;br&gt;
so here are some points which will be discussed here…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Async/await,&lt;br&gt;
When it comes,&lt;br&gt;
Why it come,&lt;br&gt;
Where we are using it,&lt;br&gt;
How it is working,&lt;br&gt;
How we can use it,&lt;br&gt;
Advantages and Disadvantages.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q1. What is Async/await 🤔?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is a concept that comes into play to handle asynchronous operations like file reading and writing, getting data from an API, etc. It addresses improving the readability and maintainability of our code. That makes our code look synchronized, which can help read and debug it. It is used in some languages like JavaScript, Python, and C#.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q2. When it comes?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It was added to the support list in 2017 as part of ECMAScript 2017.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q3. Why did it come?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It comes to handling Asynchronous operations to perform non-blocking operations without blocking other operations which takes time to execute. This is securing our code to issues that arose from nesting call-back (Call-back-Hell or pyramid of doom), like:- HTTP requests, fetching data from APIs, Network requests, File I/O, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q4. Where we are using it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is mainly used in places where you need to perform asynchronous operations: -&lt;br&gt;
Web Development:- Fetching data from API, handling HTTP requests.&lt;br&gt;
-File I/O:- Reading or writing Files&lt;br&gt;
-Databases:- Databases queries for performing all queries asynchronously.&lt;br&gt;
-Concurrency:- Managing concurrent tasks and ensuring non-blocking code execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q5. How does it work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As I mentioned. It performs non-blocking operations. There are two keywords that define their roles in performing it. What are the roles they are performing? Let’s talk about them:&lt;br&gt;
async:- We are using it to define a function as asynchronous. It is returning a promise object. Promises are objects that represent the output as a response and reject an asynchronous operation.&lt;br&gt;
await:- This can be used inside an async function. Which is holding the promise until it gets resolved. It is waiting for the promise to be fulfilled.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q6. How we can use it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While creating a function, we just need to add an async keyword before the function name and add await before the request to which it is responding.&lt;br&gt;
See the example in JavaScript below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function fetchData() {
  try {
    const response = await fetch('https://api.example.com/data');
    const data = await response.json();
    return data;
  } catch (error) {
    console.error('Error:', error);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Q7. Advantages and Disadvantages:-&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;:-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Readability:- It makes asynchronous code look synchronous which is easy to read and debug it.&lt;/li&gt;
&lt;li&gt;Error Handling:- It simplifies error handling using try and catch which helps to handle errors easily.&lt;/li&gt;
&lt;li&gt;Sequential Flow:- We can write asynchronous code which executes sequentially.&lt;/li&gt;
&lt;li&gt;Reduced call-back hell:- It is removing call-back hell to make code more readable and maintainable.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages&lt;/strong&gt;:-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Complexity: While async/await simplifies many aspects of asynchronous programming, it can be challenging to grasp the underlying concepts, especially for beginners.&lt;/li&gt;
&lt;li&gt;Compatibility: Not all environments support async/await out of the box, and transpilation may be required for older JavaScript environments.&lt;/li&gt;
&lt;li&gt;Overuse: Overusing async/await for every small operation can lead to performance issues, as it introduces overhead.&lt;/li&gt;
&lt;li&gt;Debugging: Debugging asynchronous code can still be tricky, especially when dealing with complex Promise chains.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I will appreciate your love and support if I make any mistake then please let me know and help me to improve.&lt;br&gt;
If you liked my blog and want some more information about any topics related to the below points you can add comments and I will try to give my best in it.&lt;br&gt;
-JavaScript&lt;br&gt;
-Python&lt;br&gt;
-Angular&lt;br&gt;
-Ionic&lt;br&gt;
-React&lt;br&gt;
-MongoDB&lt;br&gt;
-MySQL&lt;br&gt;
-AWS&lt;br&gt;
Thank You&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NOTE:- You can also check my Blogs on Medium:- Kritika Gaur
Hit likes add comments and follow me for more
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Rest APIs</title>
      <dc:creator>Kritika Gaur</dc:creator>
      <pubDate>Thu, 14 Sep 2023 06:21:39 +0000</pubDate>
      <link>https://dev.to/kritikag1997/rest-apis-4836</link>
      <guid>https://dev.to/kritikag1997/rest-apis-4836</guid>
      <description>&lt;p&gt;Here we are gonna learn about REST APIs with a better understanding by seeing the example of it.&lt;/p&gt;

&lt;p&gt;Representational State Transfer (REST) is an architectural style that defines a set of constraints to be used for creating web services. REST API is a way of accessing web services in a simple and flexible way without having any processing.&lt;/p&gt;

&lt;p&gt;REST technology is generally preferred to the more robust Simple Object Access Protocol (SOAP) technology because REST uses less bandwidth, and is simple and flexible making it more suitable for internet usage. It’s used to fetch or give some information from a web service. All communication done via REST API uses only HTTP requests.&lt;/p&gt;

&lt;p&gt;Working: A request is sent from the client to the server in the form of a web URL as an &lt;br&gt;
HTTP GET or POST or PUT or DELETE request. After that, a response comes back from the server in the form of a resource which can be anything like HTML, XML, Image, or JSON. But now JSON is the most popular format being used in Web Services.&lt;/p&gt;

&lt;p&gt;In HTTP there are five methods that are commonly used in a REST-based Architecture i.e., POST, GET, PUT, PATCH, and DELETE. These correspond to create, read, update, and delete (or CRUD) operations respectively. There are other methods that are less frequently used like OPTIONS and HEAD.&lt;/p&gt;

&lt;p&gt;You can get a better idea about REST APIs from this Picture&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsvzfh4vqiswso3h69p1g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsvzfh4vqiswso3h69p1g.png" alt="Image description" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GET: The HTTP GET method is used to read (or retrieve) a representation of a resource. In the safe path, GET returns a representation in XML or JSON and an HTTP response code of 200 (OK). In an error case, it most often returns a 404 (NOT FOUND) or 400 (BAD REQUEST).&lt;br&gt;
POST: The POST verb is most often utilized to create new resources. In particular, it’s used to create subordinate resources. That is subordinate to some other (e.g. parent) resource. On successful creation, return HTTP status 201, returning a Location header with a link to the newly-created resource with the 201 HTTP status.&lt;br&gt;
PUT: It is used for updating the capabilities. However, PUT can also be used to create a resource in the case where the resource ID is chosen by the client instead of by the server. In other words, if the PUT is to a URI that contains the value of a non-existent resource ID. On successful update, return 200 (or 204 if not returning any content in the body) from a PUT. If using PUT for creation, return HTTP status 201 on successful creation. PUT is not a safe operation but it’s idempotent.&lt;br&gt;
PATCH: It is used to modify capabilities. The PATCH request only needs to contain the changes to the resource, not the complete resource. This resembles PUT, but the body contains a set of instructions describing how a resource currently residing on the server should be modified to produce a new version. This means that the PATCH body should not just be a modified part of the resource but in some kind of patch languages like JSON Patch or XML Patch. PATCH is neither safe nor idempotent.&lt;br&gt;
DELETE: It is used to delete a resource identified by a URI. On successful deletion, return HTTP status 200 (OK) along with a response body.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
      <category>node</category>
    </item>
  </channel>
</rss>
