<?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: Uchechukwu Azubuko</title>
    <description>The latest articles on DEV Community by Uchechukwu Azubuko (@uche_azubuko).</description>
    <link>https://dev.to/uche_azubuko</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%2F503344%2F800a5f01-32fa-4bac-a223-94ec806427c4.jpg</url>
      <title>DEV Community: Uchechukwu Azubuko</title>
      <link>https://dev.to/uche_azubuko</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/uche_azubuko"/>
    <language>en</language>
    <item>
      <title>How to Upload Files With Vanilla JavaScript and Add a Loading Animation</title>
      <dc:creator>Uchechukwu Azubuko</dc:creator>
      <pubDate>Fri, 02 Aug 2024 16:33:14 +0000</pubDate>
      <link>https://dev.to/uche_azubuko/how-to-upload-files-with-vanilla-javascript-and-add-a-loading-animation-149j</link>
      <guid>https://dev.to/uche_azubuko/how-to-upload-files-with-vanilla-javascript-and-add-a-loading-animation-149j</guid>
      <description>&lt;p&gt;File upload is very ubiquitous to any web application and when it comes to uploading files and resources over the internet (on a browser), things can be somewhat stressful. Fortunately, with HTML 5, input elements which usually come with form control to allow users to modify data can become so handy in simplifying uploading resources.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In this article, we would have a closer look at how to handle file uploads using vanilla JavaScript. The aim is to teach you how to build a file upload component without the need for an external library and also learn some core concepts in JavaScript. You will also learn how to show the progress status of an upload as it happens.&lt;/p&gt;

&lt;p&gt;Source Code: As usual, you can tinker with the source code hosted on &lt;a href="https://github.com/UcheAzubuko/file-upload-progress-bar-javascript" rel="noopener noreferrer"&gt;GitHub repo for the project&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Project Setup
&lt;/h3&gt;

&lt;p&gt;First and foremost, in your preferred directory, create a new folder for the project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ mkdir file-upload-progress-bar-javascript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After doing so, let us now create &lt;code&gt;index.html&lt;/code&gt;, &lt;code&gt;main.css&lt;/code&gt;, and &lt;code&gt;app.js&lt;/code&gt; files where we will write all the markup for our project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ touch index.html &amp;amp;&amp;amp; touch main.css &amp;amp;&amp;amp; touch app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can begin to build the structure for the file upload by creating a basic HTML template with &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; tags:&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;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8" /&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&amp;gt;
    &amp;lt;title&amp;gt;File Upload with Progress Bar using JavaScript&amp;lt;/title&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we add base styles for the project in &lt;code&gt;main.css&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;* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To enhance the look of our applications, we will make use of the icons from the font awesome library which we can add to our project through a kit code that can be created at the official font awesome library website.&lt;/p&gt;

&lt;p&gt;Now, &lt;code&gt;index.html&lt;/code&gt; is updated, and the &lt;code&gt;main.css&lt;/code&gt; file is linked:&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;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8" /&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&amp;gt;
    &amp;lt;script
      src="https://kit.fontawesome.com/355573397a.js"
      crossorigin="anonymous"
    &amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;link rel="stylesheet" href="main.css"&amp;gt;
    &amp;lt;title&amp;gt;File Upload with Progress Bar using JavaScript&amp;lt;/title&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We continue by building the structure for the file uploader:&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;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8" /&amp;gt;
    &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=edge" /&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&amp;gt;
    &amp;lt;script
      src="https://kit.fontawesome.com/355573397a.js"
      crossorigin="anonymous"
    &amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;link rel="stylesheet" href="main.css" /&amp;gt;
    &amp;lt;title&amp;gt;File Upload with Progress Bar using JavaScript&amp;lt;/title&amp;gt;
  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div class="file-upload__wrapper"&amp;gt;
      &amp;lt;header&amp;gt;File Uploader JavaScript with Progress&amp;lt;/header&amp;gt;
      &amp;lt;div class="form-parent"&amp;gt;
        &amp;lt;form action="#" class="file-upload__form"&amp;gt;
            &amp;lt;input class="file-input" type="file" name="file" hidden /&amp;gt;
            &amp;lt;i class="fas fa-cloud-upload-alt"&amp;gt;&amp;lt;/i&amp;gt;
            &amp;lt;p&amp;gt;Browse File to Upload&amp;lt;/p&amp;gt;
          &amp;lt;/form&amp;gt;
          &amp;lt;div&amp;gt;
            &amp;lt;section class="progress-container"&amp;gt;&amp;lt;/section&amp;gt;
            &amp;lt;section class="uploaded-container"&amp;gt;&amp;lt;/section&amp;gt;
          &amp;lt;/div&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;script src="app.js"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, copy/paste the following codes to update &lt;code&gt;main.css&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;* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  min-height: 100vh;
  background: #cb67e9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Arial, Helvetica, sans-serif;
}
::selection {
  color: white;
  background: #cb67e9;
}
.file-upload__wrapper {
  width: 640px;
  background: #fff;
  border-radius: 5px;
  padding: 35px;
  box-shadow: 6px 6px 12px rgba(0, 0, 0, 0.05);
}
.file-upload__wrapper header {
  color: #cb67e9;
  font-size: 2rem;
  text-align: center;
  margin-bottom: 20px;
}
.form-parent {
  display: flex;
  align-items: center;
  gap: 30px;
  justify-content: center;
}
.file-upload__wrapper form.file-upload__form {
  height: 150px;
  border: 2px dashed #cb67e9;
  cursor: pointer;
  margin: 30px 0;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  border-radius: 6px;
  padding: 10px;
}
form.file-upload__form :where(i, p) {
  color: #cb67e9;
}
form.file-upload__form i {
  font-size: 50px;
}
form.file-upload__form p {
  font-size: 1rem;
  margin-top: 15px;
}
section .row {
  background: #e9f0ff;
  margin-bottom: 10px;
  list-style: none;
  padding: 15px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 6px;
}
section .row i {
  font-size: 2rem;
  color: #cb67e9;
}
section .details span {
  font-size: 1rem;
}
.progress-container .row .content-wrapper {
  margin-left: 15px;
  width: 100%;
}
.progress-container .details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
}
.progress-container .content .progress-bar-wrapper {
  height: 10px;
  width: 100%;
  margin-bottom: 5px;
  background: #fff;
  border-radius: 30px;
}
.content .progress-bar .progress-wrapper {
  height: 100%;
  background: #cb67e9;
  width: 0%;
  border-radius: 6px;
}
.uploaded-container {
  overflow-y: scroll;
  max-height: 230px;
}
.uploaded-container.onprogress {
  max-height: 160px;
}
.uploaded-container .row .content-wrapper {
  display: flex;
  align-items: center;
}
.uploaded-container .row .details-wrapper {
  display: flex;
  flex-direction: column;
  margin-left: 15px;
}
.uploaded-container .row .details-wrapper .name span {
  color: green;
  font-size: 10px;
}
.uploaded-container .row .details-wrapper .file-size {
  color: #404040;
  font-size: 11px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the component should be looking better on the browser:&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding Upload Functionality
&lt;/h3&gt;

&lt;p&gt;To add the required functionality for uploading in our project, we now make use of the &lt;code&gt;app.js&lt;/code&gt; file, where we write JavaScript codes that give life to our project.&lt;/p&gt;

&lt;p&gt;Copy/paste the following into &lt;code&gt;app.js&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 uploadForm = document.querySelector(".file-upload__form");
const myInput = document.querySelector(".file-input");
const progressContainer = document.querySelector(".progress-container");
const uploadedContainer = document.querySelector(".uploaded-container");
uploadForm.addEventListener("click", () =&amp;gt; {
  myInput.click();
});
myInput.onchange = ({ target }) =&amp;gt; {
  let file = target.files[0];
  if (file) {
    let fileName = file.name;
    if (fileName.length &amp;gt;= 12) {
      let splitName = fileName.split(".");
      fileName = splitName[0].substring(0, 13) + "... ." + splitName[1];
    }
    uploadFile(fileName);
  }
};
function uploadFile(name) {
  let xhrRequest = new XMLHttpRequest();
  const endpoint = "uploadFile.php";
  xhrRequest.open("POST", endpoint);
  xhrRequest.upload.addEventListener("progress", ({ loaded, total }) =&amp;gt; {
    let fileLoaded = Math.floor((loaded / total) * 100);
    let fileTotal = Math.floor(total / 1000);
    let fileSize;
    fileTotal &amp;lt; 1024
      ? (fileSize = fileTotal + " KB")
      : (fileSize = (loaded / (1024 * 1024)).toFixed(2) + " MB");
    let progressMarkup = `&amp;lt;li class="row"&amp;gt;
                          &amp;lt;i class="fas fa-file-alt"&amp;gt;&amp;lt;/i&amp;gt;
                          &amp;lt;div class="content-wrapper"&amp;gt;
                            &amp;lt;div class="details-wrapper"&amp;gt;
                              &amp;lt;span class="name"&amp;gt;${name} | &amp;lt;span&amp;gt;Uploading&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;
                              &amp;lt;span class="percent"&amp;gt;${fileLoaded}%&amp;lt;/span&amp;gt;
                            &amp;lt;/div&amp;gt;
                            &amp;lt;div class="progress-bar-wrapper"&amp;gt;
                              &amp;lt;div class="progress-wrapper" style="width: ${fileLoaded}%"&amp;gt;&amp;lt;/div&amp;gt;
                            &amp;lt;/div&amp;gt;
                          &amp;lt;/div&amp;gt;
                        &amp;lt;/li&amp;gt;`;
    uploadedContainer.classList.add("onprogress");
    progressContainer.innerHTML = progressMarkup;
    if (loaded == total) {
      progressContainer.innerHTML = "";
      let uploadedMarkup = `&amp;lt;li class="row"&amp;gt;
                            &amp;lt;div class="content-wrapper upload"&amp;gt;
                              &amp;lt;i class="fas fa-file-alt"&amp;gt;&amp;lt;/i&amp;gt;
                              &amp;lt;div class="details-wrapper"&amp;gt;
                                &amp;lt;span class="name"&amp;gt;${name} | &amp;lt;span&amp;gt;Uploaded&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;
                                &amp;lt;span class="file-size"&amp;gt;${fileSize}&amp;lt;/span&amp;gt;
                              &amp;lt;/div&amp;gt;
                            &amp;lt;/div&amp;gt;
                          &amp;lt;/li&amp;gt;`;
      uploadedContainer.classList.remove("onprogress");
      uploadedContainer.insertAdjacentHTML("afterbegin", uploadedMarkup);
    }
  });
  let data = new FormData(uploadForm);
  xhrRequest.send(data);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What we have done is to be able to read a file that has been selected from using the file input element, and create a new list of files on the DOM. When the file is being uploaded, the progress level is shown, and when the file is completed uploaded, the progress status changes to uploaded.&lt;/p&gt;

&lt;p&gt;Then, we also add an &lt;code&gt;uploadFile.php&lt;/code&gt; to our project to mock an endpoint for sending files. The reason for this is to simulate asynchronosity in our project so that we get the progress loading effect.&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;?php
  $file_name =  $_FILES['file']['name'];
  $tmp_name = $_FILES['file']['tmp_name'];
  $file_up_name = time().$file_name;
  move_uploaded_file($tmp_name, "files/".$file_up_name);
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;You have been awesome to get through to this point of this article.&lt;/p&gt;

&lt;p&gt;In this tutorial, you have learned how to build a file upload component and add a progress bar to it. This can be useful when you build websites and want your users to feel included and get a sense of how slow or fast uploading a file is going. Feel free to re-use this project whenever you wish to.&lt;/p&gt;

&lt;p&gt;If you get stuck while following along with this tutorial, I suggest you upload your project on GitHub for help from other developers or you can also send a dm to me too, I'll be happy to help.&lt;/p&gt;

&lt;p&gt;Here is a link to the &lt;a href="https://github.com/UcheAzubuko/file-upload-progress-bar-javascript" rel="noopener noreferrer"&gt;GitHub repo for the project&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Relevant Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://fontawesome.com" rel="noopener noreferrer"&gt;FontAwesome Docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>php</category>
    </item>
    <item>
      <title>African software engineers are the future</title>
      <dc:creator>Uchechukwu Azubuko</dc:creator>
      <pubDate>Thu, 08 Sep 2022 21:41:34 +0000</pubDate>
      <link>https://dev.to/uche_azubuko/african-software-engineers-are-the-future-1m96</link>
      <guid>https://dev.to/uche_azubuko/african-software-engineers-are-the-future-1m96</guid>
      <description>&lt;p&gt;The tech revolution may have started at Bell Labs, but its future shall be written in Lagos, Johannesburg, Nairobi, and the capitals of Africa.&lt;/p&gt;

&lt;p&gt;In this article (the link below), I write of the youngest and fastest-growing developer population in the world, and why it can become a source for top tech talents.&lt;/p&gt;

&lt;p&gt;I hope you find it interesting! ⬇️&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bit.ly/3D6EqEh"&gt;https://bit.ly/3D6EqEh&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
      <category>startup</category>
    </item>
    <item>
      <title>How to Use TypeScript with Vue.js: Your Go-to Guide</title>
      <dc:creator>Uchechukwu Azubuko</dc:creator>
      <pubDate>Mon, 20 Jun 2022 10:28:34 +0000</pubDate>
      <link>https://dev.to/uche_azubuko/how-to-use-typescript-with-vuejs-your-go-to-guide-3j52</link>
      <guid>https://dev.to/uche_azubuko/how-to-use-typescript-with-vuejs-your-go-to-guide-3j52</guid>
      <description>&lt;p&gt;TypeScript has now become a crucial indicator sought out for in a hire, library, maintainer, or digital product. &lt;/p&gt;

&lt;p&gt;In this article (follow the link below to read the article), I have written a beginner's guide for how to use TypeScript in a Vue.js application.&lt;/p&gt;

&lt;p&gt;➡️ Have a great read!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/p/7b40f40cc3c4"&gt;How to Use TypeScript with Vue.js: Your Go-to Guide&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>vue</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A List of Frontend Communities, Newsletters, and Podcasts to Join Today!</title>
      <dc:creator>Uchechukwu Azubuko</dc:creator>
      <pubDate>Fri, 10 Dec 2021 13:48:52 +0000</pubDate>
      <link>https://dev.to/uche_azubuko/a-list-of-frontend-communities-newsletters-and-podcasts-55d2</link>
      <guid>https://dev.to/uche_azubuko/a-list-of-frontend-communities-newsletters-and-podcasts-55d2</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;If you are a frontend developer, then you're at the right place. In this article, you will discover a list of the best communities, newsletters, and podcasts you can signup for; to help you in your frontend development journey.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://5by5.tv/bigwebshow"&gt;The Big Web Show&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://umaar.com/dev-tips/"&gt;Dev Tips&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://frontendhappyhour.com/"&gt;Front End Happy Hour&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://frontendfront.com/"&gt;Front-End Front&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://frontendfocus.co/"&gt;Front-end Focus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://webplatform.news/"&gt;Web Platform News Weekly&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://shoptalkshow.com/"&gt;ShopTalk Show&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://shoptalkshow.com/"&gt;UX Design Newsletter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wdrl.info/"&gt;Web Development Reading List&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://thewebplatform.libsyn.com/"&gt;The Web Platform Podcast&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://webtoolsweekly.com/"&gt;Web Tools Weekly&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://freshbrewed.co/frontend/"&gt;Fresh Brewed Front-end&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ponyfoo.com/weekly"&gt;Pony Foo Weekly&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/newsletters/"&gt;CSS-Tricks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://syntax.fm/"&gt;syntax&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://a11yweekly.com/"&gt;Accessibility Weekly&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://css-weekly.com/archives/"&gt;CSS Weekly&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://csslayout.news/"&gt;CSS Layout News&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://js.libhunt.com/newsletter?f=es-top-d"&gt;Awesome JavaScript Newsletter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.echojs.com/"&gt;Echo JS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ecmascript-daily.github.io/"&gt;ECMAScript Daily&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://esnextnews.com/"&gt;ES.next News&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devchat.tv/js-jabber/"&gt;JavaScript Jabber&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://javascriptkicks.com/"&gt;JavaScript Kicks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://javascriptweekly.com/"&gt;JavaScript Weekly&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://react.statuscode.com/"&gt;React Status&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://changelog.com/jsparty"&gt;JS Party&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.heavybit.com/library/podcasts/jamstack-radio/"&gt;JAMStack Radio&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://devchat.tv/my-javascript-story/"&gt;My JavaScript Story&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cfe.dev/"&gt;CFE.dev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://jamstack.email/"&gt;Jamstacked Newsletter&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Are there any communities, newsletters, and podcasts that I missed out on the list? Feel free to add them to the comment section.&lt;/p&gt;

&lt;p&gt;Happy coding, friends! 👋&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Build an API using Strapi</title>
      <dc:creator>Uchechukwu Azubuko</dc:creator>
      <pubDate>Tue, 07 Dec 2021 18:06:34 +0000</pubDate>
      <link>https://dev.to/uche_azubuko/how-to-build-an-api-using-strapi-3ibf</link>
      <guid>https://dev.to/uche_azubuko/how-to-build-an-api-using-strapi-3ibf</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Ever needed to build and ship an API in very little time? Read this article to learn how to use Strapi to get the job done.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;APIs are so useful and ubiquitous in any application, and as a developer, you may be fazed by building an API in very little time. In this article, I will show you how to build a Node.js API so fast (perhaps, in 10 minutes) using the help of Strapi’s intuitive interface.&lt;/p&gt;

&lt;h4&gt;
  
  
  What You’ll Learn
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;How to build an API quickly with Strapi.&lt;/li&gt;
&lt;li&gt;How to build a Node backend without writing Node code.&lt;/li&gt;
&lt;li&gt;How to manage relational fields with Strapi.&lt;/li&gt;
&lt;li&gt;How to add GraphQL endpoints to fetch and mutate your API.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  This Article Is Written For
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Developers that need to build backend APIs quickly.&lt;/li&gt;
&lt;li&gt;Developers that want to build a backend, but only want to focus on the frontend.&lt;/li&gt;
&lt;li&gt;Developers that want to build a Node backend API, but don’t have the Node expertise.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  What You Will Build
&lt;/h4&gt;

&lt;p&gt;In this article, you will start from scratch (i.e., from an empty directory), then you will go through all the steps needed to build an API using Strapi. The API that you will build will allow clients to make requests to manipulate content. The content, in this case, will represent blog posts (as in, for a blogging website - if you’d like to build out the frontend, moving forward.)&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;What you’ll need for this tutorial:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Knowledge of API; it might make sense to learn about it first. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Node &amp;amp; NPM - You’ll need to have Node and NPM installed on your local machine. To confirm they’re installed, run the following commands in your terminal:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node -v &amp;amp;&amp;amp; npm --v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Node Package Manager comes installed with Node. If you don’t have them installed, you can follow the instructions on the official &lt;a href="https://nodejs.org/" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt; website.&lt;/p&gt;

&lt;p&gt;This tutorial was completed using Node v14.18.1.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Yarn - Yarn is a package manager that would help us manage our application dependencies in a way that is several times faster and more reliable than NPM. You can install yarn using:
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Table of Contents
&lt;/h3&gt;

&lt;p&gt;Here’s what we’ll cover today:&lt;/p&gt;

&lt;p&gt;👋 Intro to Strapi&lt;br&gt;
⚙️ Setting up the Strapi project&lt;br&gt;
🏗️ Building the Strapi backend&lt;br&gt;
🤝 Understanding and using relations in Strapi&lt;br&gt;
⚡ Delivering faster with GraphQL and Strapi&lt;br&gt;
🤔 Conclusion&lt;/p&gt;

&lt;h3&gt;
  
  
  Intro to Strapi
&lt;/h3&gt;

&lt;p&gt;Strapi is an open-source headless CMS (Content Management System) based on Node.js that gives developers the ability to easily build self-hosted, customizable, and performant content APIs (RESTful and GraphQL). With Strapi, weeks of API development can be saved, because it’s no-code, and building a robust API could be done in less than 20 minutes.&lt;/p&gt;

&lt;p&gt;Isn’t that awesome? I thought so too. Let’s dive right into how that can be made possible.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting up the Strapi project
&lt;/h3&gt;

&lt;p&gt;There are various ways to &lt;a href="https://strapi.io/documentation/developer-docs/latest/setup-deployment-guides/installation.html" rel="noopener noreferrer"&gt;install&lt;/a&gt; a new Strapi project. However, the Strapi CLI is the best way to get started.&lt;/p&gt;

&lt;p&gt;For starters, open a terminal and navigate to the directory where you’d like to create this project. Run the following command in your terminal to scaffold a new Strapi project:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn create strapi-app my-project --quickstart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Using the &lt;code&gt;--quickstart&lt;/code&gt; flag at the end of the command provides you with the &lt;a href="https://www.sqlite.org/" rel="noopener noreferrer"&gt;SQLite&lt;/a&gt; database by default, and directly creates the project in quickstart mode. If you’d like to switch databases, &lt;a href="https://strapi.gitee.io/documentation/3.0.0-beta.x/guides/databases.html" rel="noopener noreferrer"&gt;read more&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When project creation is completed, the app should automatically start at &lt;a href="http://localhost:1337" rel="noopener noreferrer"&gt;localhost:1337&lt;/a&gt; on your browser.&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638058550273_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638058550273_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your app didn’t automatically start, run the following command in the project folder:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn develop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Open up the app folder with your IDE, and the project structure should look like mine below:&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638116197881_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638116197881_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Building the Strapi backend
&lt;/h3&gt;

&lt;p&gt;With the project folder now created, the first step to building a Strapi backend is to register an admin.&lt;/p&gt;

&lt;p&gt;You can register an admin by filling the form that was provided on startup, as I have done below:&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638058810499_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638058810499_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, click on the “LET’S START” button. This will create your account and take you to the Strapi admin UI, which you will use for development configurations.&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638062668087_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638062668087_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Isn’t it amazing how you moved from &lt;code&gt;yarn create&lt;/code&gt; to having a dashboard where you can create your very own API pretty soon?&lt;/p&gt;

&lt;p&gt;At this point, you are ready to use the awesome powers of Strapi in &lt;strong&gt;building an API for blog posts&lt;/strong&gt;. Let’s proceed.&lt;/p&gt;

&lt;h4&gt;
  
  
  Designing the data structure
&lt;/h4&gt;

&lt;p&gt;At this point, we are going to start creating the data structure for our API. We can do this by creating content-types. The first content type we will build is for posts.&lt;/p&gt;

&lt;p&gt;Go to the &lt;code&gt;Content-Types Builder&lt;/code&gt; section and click on &lt;code&gt;Create new collection type&lt;/code&gt;. A modal will appear, where you will enter &lt;code&gt;post&lt;/code&gt; as the display name.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;The Content-Types Builder allows to create and update content-types: single and collection types. &lt;a href="https://strapi.io/documentation/user-docs/latest/content-types-builder/creating-new-content-type.html#creating-a-new-content-type" rel="noopener noreferrer"&gt;Read more&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then, a modal will appear which you will use to create the fields for the &lt;code&gt;post&lt;/code&gt; content-type.&lt;/p&gt;

&lt;p&gt;Hmm, what fields does a blog post always have… Let’s create the following ones:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;title&lt;/code&gt; with type &lt;strong&gt;Text&lt;/strong&gt; (&lt;strong&gt;required&lt;/strong&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;content&lt;/code&gt; with type &lt;strong&gt;Rich Text&lt;/strong&gt; (&lt;strong&gt;required&lt;/strong&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;image&lt;/code&gt; with type &lt;strong&gt;Media&lt;/strong&gt; (&lt;strong&gt;Single image&lt;/strong&gt;) and (&lt;strong&gt;required&lt;/strong&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;author&lt;/code&gt; with type &lt;strong&gt;Text&lt;/strong&gt; (&lt;strong&gt;required&lt;/strong&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, you have a &lt;code&gt;post&lt;/code&gt; content-type with 4 fields - Text, Rich Text, Media, and Text.&lt;/p&gt;

&lt;p&gt;Hit &lt;strong&gt;Finish&lt;/strong&gt;, then &lt;strong&gt;Save&lt;/strong&gt;! Here you go, your first content-type has been created, and you have successfully created the schema for a blog post.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Schemas help to implement the database’s design. Database schemas are the blueprints that help developers visualize how databases should be built. They provide a reference point that indicates what fields of information the project contains.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638113888351_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638113888351_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, on the sidebar, we will see the “COLLECTION TYPES” section and if you go to the post section, you’ll find there are currently no posts.&lt;/p&gt;

&lt;p&gt;You can create a brand new post by clicking &lt;strong&gt;Add new posts&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You’ll see that you are provided with a CMS for inputting data. Go ahead and fill up the fields (title, featured image, author, content) with information about the first post you’d like to add to your database. You can add lots of posts if you’d like.&lt;/p&gt;

&lt;p&gt;Then hit &lt;strong&gt;Save&lt;/strong&gt;, and &lt;strong&gt;Publish&lt;/strong&gt;. A screenshot of mine is shown below:&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638114103028_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638114103028_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To view the &lt;code&gt;posts&lt;/code&gt; API, visit &lt;a href="http://localhost:1337/posts" rel="noopener noreferrer"&gt;localhost:1337/posts&lt;/a&gt;. P.s.: Notice it pluralized the name of the collection type that we had set initially - post.&lt;/p&gt;

&lt;p&gt;You will get a status 403 - forbidden error, as shown below:&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638105741189_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638105741189_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s because we attempted to view the API as an unauthenticated user, and by default, viewing an API requires authentication. To make posts public, we have to grant read-access to the post content-type. To do this, head to the dashboard and under the “GENERAL” section.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on the &lt;strong&gt;Settings&lt;/strong&gt; then &lt;strong&gt;Roles &amp;amp; Permission&lt;/strong&gt; and click on the &lt;code&gt;public&lt;/code&gt; role.&lt;/li&gt;
&lt;li&gt;Check the article &lt;code&gt;find&lt;/code&gt; and &lt;code&gt;findone&lt;/code&gt; options under permission and save.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With these, you have permitted a public user to get all posts &lt;code&gt;**GET**&lt;/code&gt; &lt;code&gt;/posts&lt;/code&gt;, and also get a single post &lt;code&gt;**GET**&lt;/code&gt; &lt;code&gt;/posts/:id&lt;/code&gt;; something so similar to the REST API GET method.&lt;/p&gt;

&lt;p&gt;Then hit &lt;strong&gt;Save&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;Now, if we head over to &lt;a href="http://localhost:1337/posts" rel="noopener noreferrer"&gt;localhost:1337/posts&lt;/a&gt; you should now see all your posts from the post endpoint this time.&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638114178599_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638114178599_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can access created endpoints with REST API methods, because by default, Strapi provides our endpoints via REST, but later in this article, I will show you how endpoints can be accessed via GraphQL&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;In the project folder, the &lt;code&gt;./api/**/config/routes.json&lt;/code&gt; files define all available endpoints for the clients. By default, Strapi generates endpoints for all your Content Types. &lt;a href="https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#routing" rel="noopener noreferrer"&gt;Read more&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Looks like we’re making progress. Doesn’t it?&lt;/p&gt;

&lt;p&gt;Now we have created a post, the content is stored in your database so that you can have access to your data when you need to.&lt;/p&gt;

&lt;p&gt;If you look through the &lt;code&gt;posts&lt;/code&gt; endpoint, you’d notice that one other benefit of Strapi is that it supports image optimization too. You are given the ability to render different image formats including thumbnail, large, medium, and small.&lt;/p&gt;

&lt;p&gt;With Strapi, you also don’t have to go through the stress of building out an MVC project structure - creating a database, database connections, models, etc. Here, it’s all done under the hood for you. We’ll have a look at that pretty soon.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Isn’t it beautiful to see that we are making headway?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Back in your IDE, you will now see that a &lt;code&gt;./api/posts/&lt;/code&gt; folder has been created in the project folder, which is a reflection of the &lt;code&gt;posts&lt;/code&gt; endpoint you created on the admin panel.&lt;/p&gt;

&lt;p&gt;In the models folder, the &lt;code&gt;posts.settings.json&lt;/code&gt; file defines the &lt;code&gt;post&lt;/code&gt; schema that you created, as shown below:&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638116163053_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638116163053_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As your app grows -- the more content-types(endpoints) you add up, the more folders are created in the api directory.&lt;/p&gt;

&lt;p&gt;Also, note that image uploads are stored in the &lt;code&gt;public/uploads&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I feel it makes huge sense that all of your code corresponds to all actions made on the dashboard. What do you think?&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding and using relations in Strapi
&lt;/h3&gt;

&lt;p&gt;Let’s say you have a collection of videos, and for each blog post; a video should be embedded within. To establish a connection between a video from the videos collection and its associated blog post, you first have to learn how to use relations in Strapi. &lt;/p&gt;

&lt;p&gt;Relation-type fields added to a content-type from the Content-Types Builder allow to establish a relation with another content-type - mandatorily a collection type. These fields are called "relational fields".&lt;/p&gt;

&lt;p&gt;With our new-found knowledge, let’s go ahead and create the video collection - to demonstrate how to set up relations in Strapi.&lt;/p&gt;

&lt;p&gt;Go to the &lt;code&gt;Content-Types Builder&lt;/code&gt; section and click on &lt;code&gt;Create new collection type&lt;/code&gt;. Enter &lt;code&gt;video&lt;/code&gt; as the display name.&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638116918626_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638116918626_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then add the following field for the video content-type:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;url&lt;/code&gt; with type &lt;strong&gt;Text&lt;/strong&gt; (&lt;strong&gt;required&lt;/strong&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hit &lt;strong&gt;Finish&lt;/strong&gt;, then &lt;strong&gt;Save&lt;/strong&gt;! Now, your second content-type has been created, and you have successfully created the schema for a video.&lt;/p&gt;

&lt;p&gt;To continue, grab a video URL, perhaps the one for your favorite YouTube video.&lt;/p&gt;

&lt;p&gt;Because we want to create a link between the post collection and the video collection, we also need to add a new field called &lt;code&gt;video&lt;/code&gt; in the &lt;code&gt;Posts&lt;/code&gt; collection. The field type for this would be &lt;strong&gt;Relation&lt;/strong&gt;, and we can choose the kind of relationship we want between &lt;code&gt;posts&lt;/code&gt; and &lt;code&gt;videos&lt;/code&gt; (by selecting any of the 6 options), to keep things simple in this demonstration, we’ll choose the one to one relationship where a post has a video, as shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: For a field to be a relation, it has to be a collection type.&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638117989452_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638117989452_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hit the &lt;strong&gt;Finish&lt;/strong&gt; button when you’re done.&lt;/p&gt;

&lt;p&gt;Now your post schema should look 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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638118149661_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638118149661_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With these, the video field in the &lt;code&gt;Posts&lt;/code&gt; collection has a relation with the &lt;code&gt;Videos&lt;/code&gt; collection.&lt;/p&gt;

&lt;p&gt;To continue, navigate to the &lt;strong&gt;Videos&lt;/strong&gt; sections under the “COLLECTION TYPES” in your dashboard, then click the &lt;strong&gt;Add New Video&lt;/strong&gt; button to add a video to your &lt;code&gt;Videos&lt;/code&gt; collection as shown below:&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638118476871_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638118476871_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hit &lt;strong&gt;Save&lt;/strong&gt;, then &lt;strong&gt;Publish&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;With the video added, we can now link it with a blog post, by heading to the post of choice in the Posts collection, clicking the &lt;strong&gt;Edit&lt;/strong&gt; button, and selecting the video URL you’d like to add to that post.&lt;/p&gt;

&lt;p&gt;Tadaa! If you visit &lt;a href="http://localhost:1337/posts" rel="noopener noreferrer"&gt;localhost:1337/posts&lt;/a&gt; on your browser, you will see that the &lt;code&gt;posts&lt;/code&gt; endpoint has been updated and the video has been added to the post where you included it, as shown below:&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638120192039_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638120192039_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Delivering faster with GraphQL and Strapi
&lt;/h3&gt;

&lt;p&gt;Delivering applications faster is always a top priority. In this section, you will learn how to easily query your data through a generated GraphQL schema.&lt;/p&gt;

&lt;p&gt;To get started with GraphQL in your app, you first have to install the plugin by running the following command in your project directory:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn strapi install graphql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;With the GraphQL plugin installed, you will be able to add a GraphQL endpoint to fetch and mutate your content.&lt;/p&gt;

&lt;p&gt;Restart the app using:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn develop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;When you visit &lt;a href="http://localhost:1337/graphql" rel="noopener noreferrer"&gt;localhost:1337/graphql&lt;/a&gt; in your browser, you should see the interface (&lt;strong&gt;GraphQL Playground&lt;/strong&gt;) that will help you to write a GraphQL query to explore your data&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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638202593800_image.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%2Fpaper-attachments.dropbox.com%2Fs_EA40404FBBCC4B6AC68C86E59D06B777193FAD00C474FA40A98AAE13F8E620D5_1638202593800_image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’d like to access the id, title, url of the featured image, author, and url of the video for blog posts, you can write the query as I’ve shown below:&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%2Fooigo66dg7l79utur7ma.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%2Fooigo66dg7l79utur7ma.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We were able to grab data pretty fast and conveniently! Also, using the sidebar, you can have a peek at your schema. Awesome!&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this article, you learned how fast, easy to use, and powerful Strapi is for building APIs. Setting up our backend was super seamless. Just create your collections and Strapi generates RESTful endpoints by default, or if you’d prefer to use GraphQL endpoints, simply install the plugin. All of these, using best web practices. Awesome stuff, indeed!&lt;/p&gt;

&lt;p&gt;If you have any questions or suggestions, feel free to post a comment, &lt;a href="//mailto:azubukouche@yahoo.com"&gt;email&lt;/a&gt;, or &lt;a href="https://twitter.com/UcheAzubuko" rel="noopener noreferrer"&gt;DM&lt;/a&gt; me.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://strapi.io/documentation/developer-docs/latest/getting-started/introduction.html" rel="noopener noreferrer"&gt;Strapi developer documentation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
