<?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: Alayaki Adedamola</title>
    <description>The latest articles on DEV Community by Alayaki Adedamola (@hatooom_laski).</description>
    <link>https://dev.to/hatooom_laski</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%2F2373194%2F94024819-e838-46d8-a6bd-bcf1f751bef1.png</url>
      <title>DEV Community: Alayaki Adedamola</title>
      <link>https://dev.to/hatooom_laski</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hatooom_laski"/>
    <language>en</language>
    <item>
      <title>REQUEST METHODS IN EXPRESS.JS</title>
      <dc:creator>Alayaki Adedamola</dc:creator>
      <pubDate>Mon, 16 Dec 2024 12:03:33 +0000</pubDate>
      <link>https://dev.to/hatooom_laski/request-methods-in-expressjs-31k1</link>
      <guid>https://dev.to/hatooom_laski/request-methods-in-expressjs-31k1</guid>
      <description>&lt;p&gt;Today is another day to share one or two things in my learning journey as regards Backend development.&lt;br&gt;
I'll be sharing about HTTP REQUEST Methods(which is Used to access details about the incoming HTTP request), and i'll be writing about 6 request methods which include;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;req.params&lt;/li&gt;
&lt;li&gt;req.query&lt;/li&gt;
&lt;li&gt;req.body&lt;/li&gt;
&lt;li&gt;req.header&lt;/li&gt;
&lt;li&gt;req.method&lt;/li&gt;
&lt;li&gt;req.url&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now let's dive in and treat them one-by-one&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;REQ.PARAMS&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
req.params is an object that contains key-value pairs representing parameters extracted from the URL path. It's particularly useful for dynamic routing, where you define routes with placeholders.&lt;br&gt;
Common Use Cases:&lt;/p&gt;

&lt;p&gt;Fetching Specific Resources:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Retrieve a specific user by their ID.&lt;/li&gt;
&lt;li&gt;Load a particular product based on its ID and category.
Building Dynamic URLs:&lt;/li&gt;
&lt;li&gt;Generate URLs for specific resources.&lt;/li&gt;
&lt;li&gt;Implementing RESTful APIs:
Create routes for CRUD operations (Create, Read, Update, Delete) on resources.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By effectively using req.params, you can create dynamic and flexible web applications with Express.js.&lt;/p&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fgauqu50mufj82omd8vpb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fgauqu50mufj82omd8vpb.png" alt="Image description" width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;REQ.QUERY&lt;/u&gt;&lt;/strong&gt;
req.query is an object in Express.js that contains key-value pairs representing query parameters from the URL. Query parameters are typically used to filter, sort, or paginate data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&lt;br&gt;
Consider a URL like &lt;a href="http://localhost:3000/search?q=javascript&amp;amp;page=2" rel="noopener noreferrer"&gt;http://localhost:3000/search?q=javascript&amp;amp;page=2&lt;/a&gt;. In this case, req.query would be:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F2ogrx7qthl3jug4jhc1n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F2ogrx7qthl3jug4jhc1n.png" alt="Image description" width="588" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can access the query parameters using dot notation on the req.query object:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fyeyt860gdar1ug7xol8l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fyeyt860gdar1ug7xol8l.png" alt="Image description" width="800" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By understanding and effectively using req.query, you can create dynamic and user-friendly web applications that can handle complex search and filtering scenarios.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;REQ.BODY&lt;/u&gt;&lt;/strong&gt;
req.body is an object that contains the parsed request body. It's commonly used to access data sent from HTML forms, AJAX requests, or API calls.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To access the request body, you'll typically need to use a body-parsing middleware. The most common middleware for this is body-parser.&lt;/p&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fbowpv07hbijn2hbusiga.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fbowpv07hbijn2hbusiga.png" alt="Image description" width="800" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;req.body can be used for Handling form submissions, Processing API requests, Building RESTful APIs.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;u&gt;&lt;strong&gt;REQ.HEADER&lt;/strong&gt;&lt;/u&gt;
req.headers is an object containing all the headers sent in the HTTP request. Headers provide additional information about the request, such as the client's browser type, preferred language, or authorization credentials.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fjgt45l4o9ogngtk06jz9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fjgt45l4o9ogngtk06jz9.png" alt="Image description" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Common Uses:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Identifying the Client&lt;/strong&gt;: Determines the user's browser and operating system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Handling Authentication&lt;/strong&gt;: Extract authentication tokens from authorization headers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customizing Responses&lt;/strong&gt;: Tailor responses based on the client's preferred language or device type.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate Limiting&lt;/strong&gt;: Implement rate limiting based on the client's IP address or other headers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By understanding and effectively using req.headers, you can build robust and secure web applications that can adapt to different client environments and implement advanced security features&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;REQ.METHOD&lt;/u&gt;&lt;/strong&gt;
req.method is a property that contains the HTTP method of the incoming request. This property is essential for routing and handling different types of requests, such as GET, POST, PUT, DELETE, etc&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fkezsvili12r3il85zb8s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fkezsvili12r3il85zb8s.png" alt="Image description" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By understanding and effectively using req.method, you can build robust and flexible web applications that can handle a variety of HTTP requests and provide appropriate responses.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;u&gt;REQ.URL&lt;/u&gt;&lt;/strong&gt;
req.url is a property that contains the URL path of the incoming request. This property is useful for:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Routing: Matching incoming requests to specific routes.&lt;br&gt;
Logging: Logging the requested URL for debugging or analytics.&lt;/p&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fv5bw3lrp4g147civ81q8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fv5bw3lrp4g147civ81q8.png" alt="Image description" width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By understanding and effectively using req.url, you can create robust and secure web applications that can handle a variety of URL patterns and provide appropriate responses.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Sychronous VS Asynchronous Javascript</title>
      <dc:creator>Alayaki Adedamola</dc:creator>
      <pubDate>Tue, 03 Dec 2024 19:36:49 +0000</pubDate>
      <link>https://dev.to/hatooom_laski/sychronous-vs-asynchronous-javascript-1n8h</link>
      <guid>https://dev.to/hatooom_laski/sychronous-vs-asynchronous-javascript-1n8h</guid>
      <description>&lt;p&gt;Today, i'll be writing about Sychronous and Asynchronous Javascript.&lt;br&gt;
Fistly, the definitions;&lt;br&gt;
Synchronous tasks happen in order i.e you must finish the first job before moving on to the next. On the flip side, you can execute asynchronous jobs in any order or even simultaneously.&lt;/p&gt;

&lt;p&gt;Asynchronous is a non-blocking architecture, so the execution of one task isn’t dependent on another. Tasks can run simultaneously.&lt;/p&gt;

&lt;p&gt;Synchronous is a blocking architecture, so the execution of each operation depends on completing the one before it. Each task requires an answer before moving on to the next iteration.&lt;/p&gt;

&lt;p&gt;Basically, Javascript is a single-threaded, blocking, sychronous scripting language used to make web pages interactive.&lt;br&gt;
Being single-threaded and blocking means that javascript can only execute one task at a time i.e The program will execute the tasks in sequence, and each task must complete before the next task starts.&lt;/p&gt;

&lt;p&gt;Although it’s synchronous by nature, JavaScript benefits from an asynchronous process. Long-running JavaScript functions can make the user interface (UI) or server unresponsive until the function has returned, resulting in a less-than-stellar user experience.&lt;br&gt;
However, there are some instances where users can benefit from blocking programming, for example, when making an online payment.&lt;/p&gt;

&lt;p&gt;The benefit of JavaScript is that it offers the best of both worlds: Single-thread and multi-thread, blocking and non-blocking. With this flexibility, programmers can write code in a single programming language instead of two—one for synchronous operations and another for asynchronous operations.&lt;/p&gt;

&lt;p&gt;Asynchronous programming enhances the user experience by decreasing the lag time between when a function is called and when the value of that function is returned. Async programming translates to a faster, more seamless flow in the real world.&lt;br&gt;
For example, users want their apps to run fast, but fetching data from an API takes time. In these cases, asynchronous programming helps the app screen load more quickly, improving the user experience.&lt;/p&gt;

&lt;p&gt;Synchronous programming, on the other hand, is advantageous for developers. Synchronous programming is much easier to code. It’s well supported among all programming languages, and as the default programming method, developers don’t have to spend time learning something new that could open the door to bugs.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;HOW TO CHOOSE BETWEEN ASYNCHRONOUS AND SYNCHRONOUS PROGRAMMING&lt;/u&gt;&lt;br&gt;
When deciding which approach to take, consider asynchronous programming adaptable and synchronous programming strict.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Asynchronous programming&lt;/strong&gt; is the multitasker, moving from one to-do to the other and alerting the system when each task is complete. Synchronous programming functions with a one-track mind, checking off one task at a time in a rigid sequence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Asynchronous programming&lt;/strong&gt; allows more things to be done simultaneously and is typically used to enhance the user experience by providing an effortless, quick-loading flow.&lt;br&gt;
Synchronous programming is best utilized in reactive systems. While it is simpler for developers to code and is recognized by every programming language, sync is resource-intensive and can slow things down.&lt;/p&gt;

&lt;p&gt;Below, i'll give some examples to better explain synchronous and asynchronous programming.&lt;br&gt;
SYNCHRONOUS PROGRAMMING EXAMPLE&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F7c76coaehgol9j2bt2ah.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F7c76coaehgol9j2bt2ah.png" alt="Image description" width="800" height="731"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The output for the above code is;&lt;br&gt;
Nissan 2003 true&lt;br&gt;
{ Name: 'Nissan', Year: 2003, Good: true }&lt;br&gt;
Adedamola 33 false&lt;br&gt;
A man called god 300 true&lt;/p&gt;

&lt;p&gt;In the above code snippet, all i did was to declare objects and assign values to keys.&lt;br&gt;
you'll notice that the output given is in order with the code written above.. What this implies is that if there is an error with the first object being declared, the remaining code won't run because it's supposed to run synchronously.&lt;/p&gt;

&lt;p&gt;ASYNCHRONOUS PROGRAMMING EXAMPLE&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fnhbsu1xkiio99m5sh416.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fnhbsu1xkiio99m5sh416.png" alt="Image description" width="800" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The output of the code is;&lt;br&gt;
one&lt;br&gt;
Three&lt;br&gt;
Four&lt;br&gt;
File appended successfully&lt;br&gt;
A new file has been created&lt;br&gt;
Two&lt;/p&gt;

&lt;p&gt;This is an example of asynchronous programming because the tasks were not executed in order, and also one task did not wait for another to finish before executing.&lt;br&gt;
Ideally, from the code written above, one should come before two and two should come before three and four. Also, a new file should have been created before the appending, but each task got executed based on the time it took for them to execute.&lt;br&gt;
So it further solidifies the claim that asynchronous programming allows more things to be done simultaneously.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Functions in Javascript</title>
      <dc:creator>Alayaki Adedamola</dc:creator>
      <pubDate>Wed, 27 Nov 2024 07:24:29 +0000</pubDate>
      <link>https://dev.to/hatooom_laski/functions-in-javascript-165h</link>
      <guid>https://dev.to/hatooom_laski/functions-in-javascript-165h</guid>
      <description>&lt;p&gt;I recently just started learning the basics of JavaScript, and I’d like to share something I’ve learnt so far off hand. I’ll be writing about functions in JavaScript.&lt;br&gt;
A function is used to perform a task or calculate a value in JavaScript. It is one of the non-primitive data types that we have in JavaScript(the other two are objects and arrays).&lt;/p&gt;

&lt;p&gt;There are two ways we can write a function syntax in JavaScript, and they are; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Function(){}&lt;/li&gt;
&lt;li&gt;Const x = ()=&amp;gt;{} (here, x denotes the name of the function we’re declaring&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Both ways are syntactically correct.&lt;br&gt;
The second one is called the arrow function.&lt;br&gt;
From the function syntax, we can see that both the parentheses () and curly braces {} are constant. The parentheses is used to accept the parameters, while the curly braces accepts the logic or argument.&lt;/p&gt;

&lt;p&gt;It is very important to note that a function isn’t complete if it isn’t called or invoked, else the code will not run.&lt;br&gt;
Below is an example to illustrate everything I’ve said.&lt;/p&gt;

&lt;p&gt;Question: write a function sum that takes in two parameters a,b and adds them together.&lt;/p&gt;

&lt;p&gt;Solution: &lt;br&gt;
 const sum = (a,b) =&amp;gt; {&lt;br&gt;
 let add = a + b;&lt;br&gt;
console.log(“The sum is: ” + add)&lt;br&gt;
}&lt;br&gt;
sum(3,5)&lt;br&gt;
—————————————————————————————————&lt;br&gt;
The output will be 8.&lt;/p&gt;

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