<?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: Diti Arora</title>
    <description>The latest articles on DEV Community by Diti Arora (@ditiarora13).</description>
    <link>https://dev.to/ditiarora13</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%2F643010%2F08a70295-50e8-45cf-9d3a-e6c251e10f1b.png</url>
      <title>DEV Community: Diti Arora</title>
      <link>https://dev.to/ditiarora13</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ditiarora13"/>
    <language>en</language>
    <item>
      <title>How to work with Spotify API</title>
      <dc:creator>Diti Arora</dc:creator>
      <pubDate>Mon, 24 Oct 2022 09:34:53 +0000</pubDate>
      <link>https://dev.to/ditiarora13/how-to-work-with-spotify-api-1mhd</link>
      <guid>https://dev.to/ditiarora13/how-to-work-with-spotify-api-1mhd</guid>
      <description>&lt;p&gt;For some reason, Spotify's API makes performing even simple tasks complex. It took me a week to understand how things work with this api🥲 And that is why , in this blog, I'll be explaining how to exactly work with the same.&lt;/p&gt;

&lt;p&gt;The very first step is to go to &lt;a href="https://developer.spotify.com/dashboard"&gt;Spotify Dashboard&lt;/a&gt; and create a new project there. You cannot miss this step because the data you'll be provided with will further help you in the authentication process, we'll get to it later 👀.&lt;/p&gt;

&lt;p&gt;After creating a new project, go to the project's overview(click on the card it forms) and then edit the settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RJOcY0ZF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5kabrmzm5zp7eawjt42.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RJOcY0ZF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5kabrmzm5zp7eawjt42.png" alt="click on 'Edit settings'" width="880" height="298"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;In the settings, change the 'redirect uri' and give the URL of your localhost, at least for the time you're working locally. Basically, this is the URL to which the user will be redirected after all the authentication is done. You'll need to change it once the app is deployed.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2EWagxoH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bspf5mmnzc82wd4pxrg1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2EWagxoH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bspf5mmnzc82wd4pxrg1.png" alt="Image description" width="477" height="636"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;After you're done setting up your project in your dashboard, head back to your project. Spotify provides something called 'Client ID' and 'Client secret' for every project you have in your dashboard. Store these 2 values in your code, without these ids, the Spotify will not know if you are authorized to fetch data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const CLIENT_ID = '64929b37c6484a45899de5f0960d6931'
const CLIENT_SECRET = '...'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Make sure you don't disclose your client secret.&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Claiming your access token
&lt;/h2&gt;

&lt;p&gt;Now in order to fetch the data, you need to first be authorized, in other words have the access token. Without the access token, spotify API will throw an error that you are unauthorized. &lt;/p&gt;

&lt;p&gt;getting the token requires you to make a POST request to the spotify api. Spotify for some reason wants their post, get and other requests to be in very certain manner. So below is the code you need to use 👇🏻&lt;/p&gt;
&lt;h5&gt;
  
  
  &lt;em&gt;since i coded this whole app in ReactJs, I used useEffect to make the call.&lt;/em&gt;
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const CLIENT_ID = '64929b37c6484a45899de5f0960d6931'
const CLIENT_SECRET = '...'

useEffect(() =&amp;gt; {

  var authParams  = {
    method: 'POST',
    headers:  {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: `grant_type=client_credentials&amp;amp;client_id=${CLIENT_ID}&amp;amp;client_secret=${CLIENT_SECRET}`
  }

  fetch(`https://accounts.spotify.com/api/token`, authParams)
    .then(res =&amp;gt; res.json())
    .then(data =&amp;gt; console.log(data.access_token))

}, [])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure that the value of &lt;code&gt;Content-Type&lt;/code&gt; is should be the same as i wrote above. Also, know you know why i told you to store the client id and client secret in your code before, because without them, this POST request won't work. This code should give the access token in your console. Since you'll be needing it futhur, it's better to store it in a useState.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [token, setToken] = useState('')
const CLIENT_ID = '64929b37c6484a45899de5f0960d6931'
const CLIENT_SECRET = '...'


useEffect(() =&amp;gt; {

  var authParams  = {
    method: 'POST',
    headers:  {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: `grant_type=client_credentials&amp;amp;client_id=${CLIENT_ID}&amp;amp;client_secret=${CLIENT_SECRET}`
  }

  fetch(`https://accounts.spotify.com/api/token`, authParams)
    .then(res =&amp;gt; res.json())
    .then(data =&amp;gt; setToken(data.access_token))

}, [])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Fetching data
&lt;/h3&gt;

&lt;p&gt;At this point, our code might vary, because it depends on what data you want to fetch. It could be anything from creating a fully functioning search bar to tinkering with playlists and everything in between, A LOT COULD BE DONE. And for that, the parameters required while fetching the data will depend.&lt;/p&gt;

&lt;p&gt;Spotify even provides its own &lt;a href="https://developer.spotify.com/console/"&gt;console&lt;/a&gt; to play around with different stuff by providing some sample data. The link which needs to be fetched will be mentioned in the end points in the console itself. Do have a look at it, might make things easier to understand ;) &lt;/p&gt;

&lt;p&gt;But for now, what i wanted to do was pretty straight forward. I wanted to simply identify the track through the id of the song which was being played at the moment.&lt;/p&gt;

&lt;p&gt;So I went through the console and found the End point i had to hit&lt;br&gt;
developer.spotify.com/console/get-track/&lt;/p&gt;

&lt;p&gt;Pretty straight forward, this is how the code needs to be written 👇🏻&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  var trackParams = {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer ' + token 
    }
  }

  await fetch(`https://api.spotify.com/v1/tracks/${id}?market=ES` , trackParams)
  .then(resp =&amp;gt; resp.json())
  .then(res =&amp;gt; console.log(res)) 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As i mentioned, spotify api wants their requests to be very certain. Frankly, I'm not sure if the &lt;code&gt;Content-Type&lt;/code&gt; remains the same in all the cases, but its always provided in the console on the right side. In my case, it was &lt;code&gt;application/json&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s----Ouw2t9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jzhahn39xgrhwnqpmeuk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s----Ouw2t9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jzhahn39xgrhwnqpmeuk.png" alt="Image description" width="880" height="393"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Even in the &lt;code&gt;Authorization&lt;/code&gt; parameter, you need to have the it like the way i wrote above.&lt;/p&gt;

&lt;p&gt;After writing all this code, you should have the data in your console. And that is how you play with SpotifyAPI :)&lt;/p&gt;

&lt;p&gt;Hope i was clear while explaining things! ✨&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
      <category>api</category>
    </item>
    <item>
      <title>My first experience in Tailwind CSS 👩🏻‍💻</title>
      <dc:creator>Diti Arora</dc:creator>
      <pubDate>Mon, 13 Sep 2021 11:29:53 +0000</pubDate>
      <link>https://dev.to/xenoxdev/my-first-experience-in-tailwind-css-20lc</link>
      <guid>https://dev.to/xenoxdev/my-first-experience-in-tailwind-css-20lc</guid>
      <description>&lt;p&gt;Recently I start learning Tailwind CSS, a CSS framework that helps you write CSS way faster.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Tailwind is a utility-first CSS framework packed with classes like flex, pt-4, text-centre and rotate-90 that can be composed to build any design, directly in your markup. Basically, it lets you write CSS in the form of classes within HTML.&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;br&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites for learning Tailwind CSS
&lt;/h2&gt;

&lt;p&gt;After testing out Tailwind, below are the things you should have knowledge about before starting with Tailwind CSS -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic HTML (especially Classes and Ids)&lt;/li&gt;
&lt;li&gt;Basic CSS&lt;/li&gt;
&lt;li&gt;Mobile and Desktop responsiveness&lt;/li&gt;
&lt;li&gt;NodeJS should be pre-installed&lt;/li&gt;
&lt;li&gt;Little knowledge about npm packages&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How I started
&lt;/h2&gt;

&lt;p&gt;Tailwind is very easy to use and to get your grasp on if you have good knowledge about CSS. Since it is that same CSS we are writing but in short, there wasn't anything extra that was needed to learn before I could start learning Tailwind.&lt;/p&gt;

&lt;p&gt;To start with Tailwind, I followed the playlist of Tailwind Lab's on YouTube: &lt;a href="https://www.youtube.com/watch?v=elgqxmdVms8&amp;amp;list=PL5f_mz_zU5eXWYDXHUDOLBE0scnuJofO0" rel="noopener noreferrer"&gt;Tailwind CSS: from Zero to Production &lt;/a&gt;. This playlist really explains everything in a clear-cut and short way. I learnt how to set up a Tailwind project, that is to download all the important files( like package.json, tailwind.config file ) and other handy plugins. After been done learning about how Tailwind pretty much works, I started exploring Tailwind's documentation, which is one of the best docs I came across up till now. While fiddling with documentation and trying to implement things on my own, I learnt how to develop normal web pages with proper styling and responsiveness through Tailwind CSS. Afterwards, I jumped on to some advanced stuff like creating my own classes, how to make and use custom colours and properties!&amp;lt; br/&amp;gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Difficulties I faced
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To me, the process of setting up your Tailwind project was a little difficult at first, though as time passed everything was clear to be.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Another problem I faced was since we were styling our code inside our HTML file (classes to be precised), the code started looking very confusing especially when you have to heavily style your elements. &lt;br&gt;
&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Ease of learning
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It is not at all difficult to learn Tailwind CSS since as I mentioned it above that there is nothing extra you've got to learn as we are writing that same old CSS. &lt;br&gt;
&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tailwind's documentation has got one of the best explanations for the same, that is its core concepts, how it works, and its usage.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The classes used in tailwind are very easy and straightforward, you wouldn't need to glance back at its docs to see class names!&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;h2&gt;
  
  
  Bootstrap vs Tailwind CSS
&lt;/h2&gt;

&lt;p&gt;Bootstrap and Tailwind, both are one of the most used CSS frameworks.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Bootstrap lets you quickly design and customize responsive mobile-first sites. It's the world’s most popular front-end open-source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1.Customizability
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Tailwind according to me is very flexible(customizable). You can decide all the properties and values by yourself, and there is never any need of writing extra CSS. When talking about custom properties, you can easily build your custom colour, use external fonts, etc by making a custom property in your Tailwind config file&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Unlike Tailwind CSS, Bootstrap is not very customizable because it have pre-styled elements, and there can be times when you might consider making a CSS file for changing the default styling provided by Bootstrap and adding a bit of your own touch.&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  2.Usage with CSS Preprocessors
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Since Tailwind is a PostCSS plugin, it can easily be used with other preprocessors like Sass, Less, Stylus and others, just like you can with other PostCSS plugins like Autoprefixer.&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Bootstrap comes with vanilla CSS, but its source code utilizes the two most popular CSS preprocessors, Less and Sass. It by default comes with Sass variables and mixins.&lt;/li&gt;
&lt;/ul&gt;



&lt;h3&gt;
  
  
  3.Removal of unused classes
&lt;/h3&gt;

&lt;p&gt;Both Tailwind CSS and Bootstrap uses PurgeCSS to remove all the untouched css classes which are only helping in increasing the file size.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.Looks
&lt;/h3&gt;

&lt;p&gt;Tailwind:   &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%2Fauthors.xenox.dev%2Fcontent%2Fimages%2F2021%2F09%2Fimage-2.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%2Fauthors.xenox.dev%2Fcontent%2Fimages%2F2021%2F09%2Fimage-2.png" alt="Simple card design with Tailwind"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  A simple card design with Tailwind 👆
&lt;/h6&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fauthors.xenox.dev%2Fcontent%2Fimages%2F2021%2F09%2Fimage-3.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%2Fauthors.xenox.dev%2Fcontent%2Fimages%2F2021%2F09%2Fimage-3.png" alt="Tailwind code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  Tailwind code
&lt;/h6&gt;

&lt;p&gt;Tailwind:   &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%2Fauthors.xenox.dev%2Fcontent%2Fimages%2F2021%2F09%2Fimage-4.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%2Fauthors.xenox.dev%2Fcontent%2Fimages%2F2021%2F09%2Fimage-4.png" alt="Simple card design with Bootstrap"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  A simple card design with Bootstrap👆
&lt;/h6&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fauthors.xenox.dev%2Fcontent%2Fimages%2F2021%2F09%2Fimage-5.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%2Fauthors.xenox.dev%2Fcontent%2Fimages%2F2021%2F09%2Fimage-5.png" alt="Bootstrap code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  Bootstrap code
&lt;/h6&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Well, both look good in their own way but then again bootstrap is less customizable and I would have to write extra CSS in order to change its appearance according to my website's theme.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Below are some reasons why I believe that Tailwind is worth using-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's very beginner-friendly. 
While building web pages, you won't even need to leave your HTML file!&lt;/li&gt;
&lt;li&gt;Unlike Bootstrap, It is highly customizable&lt;/li&gt;
&lt;li&gt;You don't have to worry about unnecessary code, PurgeCSS will take care of it.&lt;/li&gt;
&lt;li&gt;It has memorable class name. So you won't need to repeatedly go back to the documentation&lt;/li&gt;
&lt;li&gt;You can even make your own classes, so you won't have to repeat the same code again and again.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Thanks for reading😃. Bye!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>showdev</category>
      <category>css</category>
    </item>
  </channel>
</rss>
