⭐ If you would like to buy me a coffee, well thank you very much that is mega kind! : https://www.buymeacoffee.com/honeyvig Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies

Tuesday, November 11, 2025

API Project! Build a Crypto Dashboard

 You need to sign up here to follow along: https://bit.ly/rapidapi-hub In this video I show you how to make a Crypto Dashboard using two APIs. This project is great for those looking for fun projects to make with unique APIs.

 

0:00

hello everyone out there on the internet today today i'm going to be showing you how to use apis in order to build out a

0:07

crypto dashboard our crypto dashboard is going to have a currency converter on it

0:12

in which we will be selecting from a list of currencies in order to convert one to the other based on a certain

0:19

amount we will also have an exchange rate display that will show us the currency live exchange rate between the

0:25

two currencies and a cryptocurrency news feed as well that will bring back seven articles along with the url that we will

0:32

encapsulate the title of the article in to get the latest data we are going to

0:37

be using two apis from rapid api one being this currency converter api

0:43

right here and the other being this crypto news api right here this tutorial is perfect for those

0:49

wanting to learn how to use apis and how to use them in react projects in order to build out their front-end developer

0:56

portfolios the only prerequisites for this video is to have a basic understanding of the fundamentals here

1:02

so css html javascript and react okay so what are we waiting for i'm

1:09

excited let's do it okay so let's do it

1:14

so here we are on the rapid api hub rapid api hub is a platform used by

1:21

developers to find and connect to hundreds and hundreds of apis as you can see right here i like to use rapid api

1:29

as i can literally scroll through all their options in a categorized way and

1:34

not only that once i have a rapid api key i can use the same key for all the

1:41

apis that you see here okay so no need to sign up to various

1:47

different platforms and manage hundreds of passwords and api keys you literally

1:53

just need one to access all of these for this tutorial the apis that we are

1:58

going to be using are this crypto news live api to get a news feed in our app

2:05

as well as this alpha vantage api that we're going to use in order to get the

2:10

cryptocurrency conversions okay so these are the two we need let's

2:17

get to it so i'm just going to bring up my ide of choice of course you are free to

2:23

use whatever ide that you wish this is just the ide that i will be using for

2:29

this tutorial and i'm just going to create a new project and this is going to be a react app so

2:36

i'm just going to click here and that will bring up the command that i need in order to spin up a pre-configured react

2:43

app okay and here is what i'm going to call my project so let's go ahead and call this crypto

2:49

dash board for those of you who have not used this

2:54

command before it's really great as it allows you to spin up a single app

2:59

application with all the files be configured so for example with all the correct dependencies and all the correct

3:05

file structure okay so let's get to it i'm just gonna click

3:11

create just like so and that should spin up my app for me

3:16

there we go you will see all the dependencies being installed all the files being created and you should see

3:22

that populating in my crypto dashboard project right here now for those of you who aren't using

3:27

webstorm you can of course do this using your terminal so i would simply go into

3:33

a directory of my choice such as development and then i would use nph create react app and just simply call

3:39

this something let's go ahead and call it crypto dashboard again and just click enter but

3:46

of course i'm not going to do it this way because i am using webstorm to do this but that is an alternative for

3:51

those of you using something like vs code for example okay

3:56

so this should be done any second and done

4:02

happy hacking okay wonderful so as i said you will see all the files being generated in here

4:09

i'm not going to talk you through this because this tutorial has the assumption that you've already worked for react so

4:14

i'm not going to talk you through what a dot get gnaw file does and what a

4:20

package json file does however just know that all the dependencies we need are

4:25

here they have been installed thanks to npx create react app but we are gonna add one more okay so i'm just gonna get

4:32

up my terminal just like so and using npm i i'm gonna install the package

4:38

axios okay so i'm just gonna let that install

4:44

and for those of you who don't know axios is a promise based http client for

4:49

the browser and node.js so we can use axios in the back end or the front end

4:54

which makes this perfect for our project if you want to have more of a read about axios and how to install it as well as

5:00

the code you need to get started please go ahead and visit mpmjs.com so the npm registry forward

5:07

slash package forward slash axios okay wonderful while that is installing i'm

5:13

just going to go in here and actually delete everything that we don't need so i'm just going to go ahead and delete

5:19

anything to do with tests and setting up web vitals as well as the logo as we will not need that so i'm simply going

5:25

to delete these files like so and delete anyway

5:31

and i'm also going to get rid of the app.css file as i want all my styling to be done in the index css file so just in

5:39

one place as this is a small project and i'm just going to get rid of this app test file too

5:45

so just like so great so now if we look in app js well

5:52

we don't have these two anymore so i'm just going to delete that i'm going to delete these semicolons just like so

5:59

and save this page i'm going to go into index yes and once again just delete everything that we don't need along with

6:05

the semicolons because i don't really like using semicolons but that is totally my choice and it's totally up to

6:11

you great so let's have a look to see if that is done and wonderful so the axios package has

6:19

been imported if you have a look in the package jason you will see it show up here along with its version okay so if

6:25

you are having any issues in the future it could be down to the fact that this package in the future is now outdated so

6:32

please go ahead and revert back to this one if that is the case same goes for all of these as well

6:38

okay wonderful so now that we have that let's continue to building our app so i'm just going to go back in here and

6:46

first of all we need to start our app so in webstorm i can simply press this button and that will run this script

6:52

right here so the start script or if you're not using webstorm all you'd have to do is go npm

6:59

run start but as we don't have to do this because we are using webstorm i'm just going to go ahead and click

7:05

here and that will spin up our app

7:11

and uh logo is not defined so let's go back to our js file and get rid of the

7:17

logo and just click save and there we go so let's just go ahead

7:23

and visit this url now and wonderful

7:29

so there we go that is essentially what is showing up here just without any styling just to show you that i am not

7:35

lying i'm going to change this to anya and it changes to anya so that is

7:40

working i'm actually going to get rid of all of this code as well as well as this

7:46

div with the class name of app as we don't have it anymore so let's just go ahead and have two wrapping

7:52

divs just like that and there we have it we now have the basic structure to start our react app

8:00

i'm just going to change this to be a function expression as well again this

8:07

is just my personal preference you could have kept it as a function if you wish great

8:12

so now that we have a blank slate well what do i want to do i want to create an app that on the right has a news feed

8:19

and on the left has a currency converter that will also show us the currency converted exchange rate

8:26

so i'm going to do this with components so i'm going to create my first component as we said i want a news feed

8:34

on the left so i'm going to create a component that will have my news feed in it so just on the same

8:41

level as the index css file i'm going to create to go new directory and i'm going

8:47

to call my directory components where i'm going to store all of my components so these components are essentially

8:53

react components and i am just going to create a new file and let's call this

8:59

newsfeed just like so and in here well just like we did with

9:07

this component right here so i could actually just copy this if i wish

9:13

and paste it in here and then rename this to news

9:18

feed making sure to rename it down here when we export it as well and of course

9:24

delete that so this is now our news feed

9:29

just like so and then perhaps just so we can actually see it as well i'm going to

9:34

give this the class name of

9:40

newsfeed great

9:46

use feed use food so this is looking good i am happy with

9:53

this let's carry on i'm actually going to copy this again because we do want to make two more components

10:00

so let's go back to here we have a news feed component and on the

10:06

left i said i wanted something to show the currency converter

10:17

so just like so so that is going to be our conver con

10:22

ver so that is going to be our second component if i spell that correctly that

10:28

looks good so once again in here i'm just going to create a new file i could

10:34

just select javascript file if i want and i'm going to call this currency converter

10:40

just like so we don't need to add js because it already knows this is a javascript

10:46

file so there we go we've got a currency converter and once again i'm just going to click on component let's call this

10:52

currency converter that's correct making sure to export default it down here and

10:58

also maybe let's give this some styling just so we can differentiate between the two so i'm going to call this

11:05

you guessed it currency converter

11:12

great so now just so we can see what's going on before we add the third component let's style it up

11:19

so in here let's go ahead and just keep that code for now i'm going to get the news feed

11:25

class so dot for class and let's just give it the background color of red for now

11:33

and then i'm also gonna get the currency

11:46

and go background color blue okay so great we've made two components i

11:53

also now need to import these components so import

11:58

news feed from and because it's an export default it actually doesn't matter what we call this okay it will

12:05

know that we want that component so we need to import it from components

12:14

news feed just like

12:19

that making sure that news feed is spelt exactly the same here so now this

12:25

whole component is being imported into my app once again like i said it doesn't matter

12:32

what we call this we can call it whatever you want as the export of the component is just a default so we just

12:38

know that whatever this is it will be imported into here as whatever we call this

12:44

great let's do the same for the currency converter so import currency

12:51

converter from components and then currency converter

12:58

so now if we look in this browser you will see the news feed and the currency converter let's perhaps just go and make

13:05

sure that this says currency converter just so we can

13:11

know which one we are talking about at all times okay so there we go news feed and currency converter however as we

13:17

said we want the news feed to be on the right and the currency converter to be on the left so i could do so easily with

13:23

some styling so let's go back in here and on this div let's just go ahead and give this the class name of

13:30

app and go back in here just above here i'm going to add a app class and i'm going

13:37

to say display

13:43

flex okay so now the two appear next to each

13:48

other wonderful while we are here i'm actually just going to give it some more styling just

13:54

to make sure that they're always uh next to each other no matter what fret selection column will just mean that

13:59

they're always next to each other and i'm going to align items in the center

14:06

okay so that is just something for the future when we start building this out a

14:11

little bit great so we have created two components however i did say i want a third and

14:17

that third component is going to show us the exchange rate so let's go ahead and

14:22

create an exchange rate component so once again in here create new file let's

14:28

make a javascript file and i'm going to call this exchange

14:35

rate we could call it display if we wish or we could just say just exchange rate

14:41

component it's up to you so i've just added that and once again

14:47

i'm just going to basically copy this because it's exactly the same and i'm going to call this exchange

14:56

rate export the exchange rate component and

15:01

let's just give it the wording of exchange right here and once again let's also give this a class name so i'm going

15:09

to call this exchange rate so there we go

15:17

i'm going to my css file and once again all i'm going to do is simply give it a background color so we can differentiate

15:25

let's go ahead and give this the background color of green great and now this time i don't want to put my

15:32

component in here okay i actually want to put it in the currency converter so i'm going go in

15:39

here and import import

15:44

exchange rate from and because we are in the same directory this will be very

15:50

easy all i need to do is essentially just go to the file so just

16:00

like that and where do i want to put it well i just want to put it below here so i'm

16:05

going to put in the component like so and now if we look here

16:12

wonderful so actually i want these flipped around so i'm just going to go ahead and do that

16:19

making sure that the news feed is after the currency converter and

16:24

great so we've got the news feed on the right we have the currency converter on the left which also includes the

16:30

exchange rate in it as a child so the exchanger is the child component of the currency exchange component which i have

16:38

missed name again let's just go currency con versa again this won't be important i'm

16:45

just showing you this for now wonderful so now that we've got that let's get to

16:53

converting some currencies so i'm going to be doing this in this component right

16:59

here so i'm just going to get rid of all the others we're not going to need them for now i will keep the css file as that

17:04

could be useful in a bit so the first thing that i'm going to do

17:10

is let's actually just create an h2 tag and put currency converter in it just so

17:16

that we know what is going on here so let's call that currency converter and now in here what i actually want to do

17:23

is create a table okay so i'm going to create a table

17:30

just like so just to make sure that everything is structured at all times so here is my table

17:37

tag and as you might all might know when we use the table tag with the jsx we

17:44

actually need to put a body tag in here as well and now we can start

17:50

making table rows so i'm going to make my first table row and in it

18:00

and in it i'm going to have a table data cell which i'm going to give some text to which is going to say

18:06

primary currency just like so so there we go

18:13

and now i'm going to have another table data cell but this time in this table

18:18

data cell i'm going to show you how all this looks like in a bit i'm going to have an input element

18:24

okay and this is going to be a self-closing tag and the input element

18:29

well i only want numbers to go in here so i'm going to give it the type of

18:36

number because currency should be in numbers

18:41

let's also give this a name for good practice so i'm going to call this currency

18:47

amount 1 and then the value which at the moment

18:52

it's not going to have a value so i'm just going to leave it as an empty string like so and let's have a look at what this looks

18:58

like so there we go we have a table which the row consists of primary

19:05

currency and then an input which allows us to select different numbers okay great

19:11

before we move on i do actually want to put this in a wrapping div just because i feel like it should all be in a

19:17

wrapping div so we can give it some extra styling around the table so i'm going to grab that entire table and put

19:24

it in this div just like so and then let's give this div a class

19:30

name of

19:36

input box as that is what we are creating and we actually need one more table data

19:42

cell so here's our first one here's our second one let's put one

19:48

last one before we move on to the next row and in this table data cell i

19:54

actually want a select element

20:00

and in this select element well i'm gonna have to put some stuff in here

20:07

so we need a value which once again i'm just gonna leave

20:12

empty for now let's also give this a name

20:20

this is going to be called currency option one as it's going to be the currency that we first choose to convert

20:25

to the other let's give this a class name of again let's just put

20:31

currency options for now not currency option one as we're

20:38

going to apply this class name to uh to select elements and then we're gonna have to have some options so i'm just

20:44

gonna leave one option for now but we will be mapping

20:51

an array onto more options making sure that is outside of here

20:57

and in between these two select tags so right now could be a good time to just reformat this just to make our code

21:04

a little bit neater format file run

21:09

okay so that is looking much neater let's carry on so now if we look in here

21:16

you will see private currency an input and a select with nothing in it to select i want two of these okay because

21:23

i want a primary currency and then the second currency as to which is converted to so i'm simply going to grab all of

21:30

this so the whole table row trs for table row and simply just paste it

21:37

again and this time let's call this secondary currency

21:43

currency amount two currency option two so whatever option

21:48

we choose and this is looking good wonderful

21:54

so now i think it's time to actually get some currency options so let's go ahead

22:02

and do that up here right under where we return the jsx so

22:09

i'm actually going to hard code these currencies this is because the api that we are using returns so many

22:16

currencies not all of them crypto and i want to make sure that they're all crypto so all i've done is simply use

22:23

this api right here the alpha vantage one and done some research on what kind

22:28

of cryptocurrencies it has and what format we need to put them in okay if you want to do your own research

22:34

please go ahead and see the documentation and read more so all i'm going to do now is use what i

22:41

have previously found again this is my research and i know that this api takes

22:46

bitcoin in that format ethereum and i'm just going to maybe copy paste the rest

22:51

because again i don't want to be here while you watching me type it out

22:57

so those are the ones we're going to convert to i do have us dollars in there as well so maybe that's not the only

23:03

cryptocurrency one but i think it's a useful one to have so there we have our currencies it's an

23:08

array and i'm going to use this array called currencies to map out the options

23:14

onto different option elements so here we have our option element and

23:21

to map onto it well i'm going to show you how to do this we need to put this in some

23:27

curly braces and then i'm going to grab the currencies array and use the javascript method of map

23:34

to map again i'm just gonna wrap that around in parenthesis and for

23:39

each item or for each currency let's call it in my currency array so for every item

23:46

that exists in this array i've called this currency i can call it i i can call it whatever i wish and for each of those

23:53

well what do i want to do so again let's just use our parenthesis to wrap the option

24:01

i want to essentially just

24:06

put the currency in between these options okay so there we go that's really it i'm going to make this smaller

24:13

for you so if we now look in here you will see my currency options

24:20

uh we are not yet done however for best practice i do need to put an index even

24:25

though we won't really be using it so as we are not going to be using it i can

24:32

simply just do index like this

24:37

okay so i pass through an index but we don't really need it it's not really that important and hence i'm putting in an underscore it can be ignored

24:44

so that means we also need to put a key on the option so i'm just going to pass through the index

24:52

ah let's have a look at our warnings now okay

24:58

apologies this should be tea body not body that is my fault

25:03

and where is the other one tea body so that has been updated

25:09

great and it's telling us to put in a value okay this we are aware of we have left it blank for now

25:15

wonderful so we finished our first select let's carry on i'm gonna also

25:20

apply to the second select so just like we did up here i'm just going to grab all of this

25:29

and also map onto the options and the second select right there so wonderful

25:35

so that is looking good the next thing we need to do is actually save the selected option to state so i'm going to

25:42

show you how to do this now so for this we're going to actually have to

25:47

import use state from react i'm going to do import use state

25:54

from react hopefully you know how to use use state if you don't please go ahead and research that now otherwise feel

26:01

free to code along with me i'll do a brief overview of what it is

26:07

so to use use state to save things to the state of this component what i have

26:12

to do is use this syntax so for example if we want to save the first

26:19

chosen currency let's choose to call this chosen primary

26:25

currency for the first select and then we're going to set

26:31

chosen primary currency like so and use used state

26:38

for now i'm going to pass through no okay so what i can do so at the moment

26:43

using use state i am saying that chosen primary currency is null but i can

26:49

change that value by using set chosen primary currency making sure that it's a

26:54

small s so i'm going to do that now i'm going to use this and on the select i'm going to say that

27:02

as soon as this changes so whenever this changes in value i'm going to pass through e4 event you

27:08

can pass through the whole event or you could just pass through if you wish and i'm going to use set

27:14

chosen primary currency to change the value of chosen currency to whatever the

27:21

value of my select is okay so hopefully that makes sense if i now

27:26

console log chosen primary currency we look in here

27:34

so let's have a look at the first one at the moment it is null because that's what we use state to set chosen primary

27:40

currency to however if i select ltc we have changed chosen primary currency to

27:46

ltc we can also get it to display in here and i can do so easily simply again

27:52

on the select changing the value to you guessed it chosen primary currency

27:58

so that is looking good now there is one thing that i just wanted to make you aware of because we

28:03

are starting at no and as you can see here it says btc this could potentially cause errors okay because we think that

28:11

we have chosen btc but the value of chosen primary currency is null so i'm

28:16

going to actually hard code this to be btc just to be in line with what we see

28:23

wonderful so we've done one let's do the other so how do you think we would do this other select

28:31

well quite simply we do it the same way so i'm simply going to copy this and we're going to do chosen secondary

28:39

currency so it's chosen secondary currency also we'll start it at btc

28:45

let's console.log chosen secondary currency just to make sure everything is working fine

28:51

and on change of the select so on

28:57

change sets chosen secondary currency to e target value and also show the chosen

29:06

secondary currency here set chosen secondary

29:12

currency it's very long i think that's fine set chosen secondary currency so now if we go here and then

29:20

let's just check this work so refresh as you will see the chosen secondary

29:27

currency is btc and if i change it to ada there we go

29:33

so wonderful we are storing the first chosen currency we are storing the

29:38

second chosen currency the next thing we need to do is

29:44

store the amount that we want to convert to state because we're going to have to send all three of these things over to

29:51

our api so as you will see here to get a

29:59

currency exchange rate for crypto here well it's asking us for the currency

30:05

we're going to change it from the currency we're going to change it to and then we are choosing to save the

30:10

amount so that we can get the exchange rate and multiply it by the amount we want to exchange

30:17

so great let's go ahead and do that so once again up here i'm going to go

30:23

const amount set amount

30:30

use state and i'm going to pass through a 1 as a default okay because we want to convert

30:37

one of a btc to whatever the currency that we choose to convert to

30:44

so at the moment amount here is the number one but we can change that using set amount so i'm going to do so on the

30:51

first input so just up here and this time once again we're going to use

30:56

unchanged

31:10

we're going to use e for event and we're going to use set

31:16

amount and pass through e target value okay so

31:22

great now we are saving all three things let's just go ahead and check if this

31:28

has worked so i'm gonna console log the amount but i'm also going to show the amount

31:34

in the input itself so let's have a look obviously one is

31:40

showing up as we used use state in order to do this and if i now change it to two

31:46

you will see the amount changing as well so we have all three things saved let's

31:52

carry on now it's time to actually use

32:03

this piece of code in our project so i'm going to hook this up i want to

32:08

say that as soon as i click a button then we make this get request so let's

32:13

go ahead and create a button i'm going to do so right at the bottom here

32:20

after the table so there we have our table let's go

32:26

ahead and create a button i will be formatting all of this a little bit better at the end let's just continue

32:31

for now and the button is going to say convert and let's go ahead and give this an id in case we want to

32:38

style this or anything like that i'm going to call it convert button just like so and i'm going to say that on a

32:44

click i want to let's possibly call back i want to

32:49

convert so this is a function that i have not yet written in fact i'm going to write it

32:55

now so i'm gonna write this function up here so const convert equals and i'm gonna

33:02

just write a function so what do i wanna happen when we press the button well i

33:07

essentially want to make a get request so i'm simply going to get all of this and i'm going to

33:14

paste that in here making sure to take this out and we're going to import axios by

33:19

ourselves here so import axios from axios this is the front and way to do it

33:26

great so we've imported the package that we installed as a dependency at the beginning of this video and we can now

33:33

use it in here as you will see we are making axios request i'm just going to tidy this up a little bit i don't want

33:39

to use var let's use const and once again let's just get rid of any curly braces and i'm just going to use arrow

33:46

functions here too so just

33:52

like that okay

33:58

so now as soon as we have all three of these well i want to make a

34:04

get requests so i'm going to replace this with the chosen primary currency

34:12

and i'm going to replace this with the chosen secondary currency so just like

34:17

that and for now let's just check this works let's just go in here

34:24

and press refresh and i'm going to keep this as a one and i'm going to change bitcoin to us dollars and click convert

34:32

and there we go we are getting back our data so as you will see here is our data it's actually

34:39

the same data that if we tested this endpoint so if i go ahead and click test endpoint we're getting the exact same

34:46

data okay so this is looking good if you haven't signed up to this now is a good

34:52

time to do so otherwise you can't test the endpoint and what we have done might not work for you so please go ahead and

34:58

sign up to use this as you will see i am subscribed this one does have some

35:03

pricing that comes along with it so we can only make 500 requests a day however as this is a personal project that

35:10

should be fine i do not expect to go over this per day okay

35:15

so wonderful let's carry on so hopefully that is now working for you

35:22

once again you do need to be subscribed in order to use this and in order to test it so if something is not working

35:29

for you it could be because you have not subscribed great okay so now that we're getting back

35:35

response i actually want to save this response once again you guessed it to state so that we can use it so i'm going

35:42

to do that down here let's save this as exchange rate as that is essentially

35:48

what we want to get from here i'm looking for the exchange rate okay that's what i want so to go into

35:56

this object i will need to go into the real-time currency exchange and

36:01

then find the exchange rate so i'm going to show you how to do this

36:07

first of all let's just set up our you stay here

36:12

so exchange rate set exchange rate use state

36:17

and i'm just going to start off with this being zero this time

36:23

okay so there we go so now there's our data however we want to go into the object

36:31

and to go into the object but by the property or key i'm going to just get

36:40

oops this right here as a string so that is what we want to get and then once i am

36:47

in that object i want to get the

36:52

the what that was cleared i'm just gonna go ahead

36:58

and let's look in here making sure that we are in digital and crypto on the

37:05

exchange rate you can have a look at sample responses so we're going to get the real-time currency exchange and then we're going

37:12

to get the currency rate so i need to get that whole string and then simply

37:18

put it in here so that should get me the exchange rate i'm also going to set this

37:25

to set exchange rate and pass through essentially this whole thing right here

37:34

okay so now if we console log

37:39

exchange rate we should see the exchange rate so let's have a look at that

37:47

so once again let's maybe let's select usd and click convert there we go we are getting the exchange

37:54

rate should we try another one let's do this one and convert and we're getting

38:00

another exchange rate so this is looking great we have a few

38:06

more things to do i actually want to display this exchange rate

38:12

multiplied by the amount that we want to convert in here so i'm going to do that next and that

38:19

will actually solve this warning for me as well so let's go ahead and do that so that is

38:26

my exchange rate another thing i want to set is the result and the result is the result of the exchange rate multiplied

38:32

by the amount so i'm just going to simply go this which is the exchange rate

38:38

and i'm going to multiply it by the amount so that should be fine this returns back

38:45

a number and this is a number however we also need to get the results so sets or

38:51

results we can do set result equals use date and i'm going to start off at zero so now i can use

38:58

result and display this in this input right here

39:06

so that is the second input and actually what i also want to do on the second input is disable it okay because i don't

39:13

want it to be tampered with i simply want it just to show the result

39:19

okay so this is looking good we don't really need to type for this as it's just

39:24

showing the result and

39:32

make sure this is a d and there we go you will now see it's

39:38

disabled and if i now select a value so two bitcoin to

39:44

us dollars and click convert amazing now i can now actually change

39:51

this and it will do another conversion for me

39:56

so this currency converter is officially now working

40:02

wonderful so hopefully that makes sense we aren't getting any warnings yet we have solved

40:07

this warning let's carry on

40:13

now i did also say that i wanted to

40:19

show my exchange rate in its own component so here's my exchange rate component

40:24

it is the one in green here i'm simply going to pass through the exchange rate

40:29

not the result into it so i can do so easily so i can go in here

40:35

and just go exchange rate and pass through the exchange rate so i'm just

40:41

passing through a prop into the exchange rate component so let's go ahead and

40:47

save that making sure that is a small e and now let's go into our

40:54

components again so the exchange rate component and i'm going to destructure the exchange rate

41:02

that i passed through and simply just show it in

41:08

here so now if we look in here you will see the exchange rate showing up not the

41:14

result but the exchange rate from one currency to another wonderful

41:20

let's carry on so now i'm going to just do some styling on this component this is going to be a very simple one all i'm

41:26

going to do is actually just have an h so an h3 tag this time

41:32

exchange rate like so and i'm going to show the

41:37

exchange rate let's put in h1 tag h1 tag

41:47

oops okay h1 just like so

41:54

making sure that's an h1 as well and then we could also pass through if

42:01

we want maybe we can pass through you know chosen primary currency to secondary currency

42:09

just so it's super clear what is happening here it is the

42:14

conversion rate from one to the other which means we just have to pass through the chosen

42:21

primary currency

42:27

and the chosen secondary currency so that is also something that we can do

42:34

it just means we need to pass them through here as well so let's just go ahead and do that

42:39

so i'm just passing them through as props and chosen primary currency i'm also

42:47

going to pass up through as a prop and then destructure it in the exchange rate so now if we look here you

42:54

will see the exchange rate and you will also see that what we are exchanging it from okay and let's just try again so

43:00

let's go ethereum to use dollars and click convert

43:09

you will see that changey great and if i increase this

43:16

convert again that will change

43:21

wonderful so i'm happy with this at the moment of

43:27

course we will style it up a lot better for now i just also need to do my news feed so let's tackle that first and then

43:33

do any styling and any other issues that may arise from what we have built so far so let's do it i'm just going to go back

43:42

to here and i'm going to get rid of the currency converter and the exchange rate

43:48

and i'm just going to open up my news feed this time so as we said for the news feed this

43:53

time we're going to use this crypto news live again please make sure you are subscribed to it so you can use it the

44:00

pricing of this isn't too bad we get 300 requests a month so this is okay for

44:05

personal projects like i said this is for building up your personal projects portfolio so please go ahead and

44:11

subscribe to this one and just make sure you don't go over 300 so my end points for this are like so i

44:18

just want to get all the articles to get all crypto news so all i'm going to do is just copy this again we don't need a

44:25

different api key it's the same api key for everyone please keep it safe i will

44:31

be deactivating my api key after this

44:36

so all i'm going to do is go back in here and this time because i just want to

44:42

get all the news articles we don't need to attach this to a button i'm going to use use effect

44:52

just like so and then in this use effect thank you for importing use effect for

44:57

me make sure that is imported from react i am just going to have no dependency so that this only

45:03

runs once and i'm going to paste all the code we just copied and again this is for back end so i need to import access

45:10

the front end way import axios from

45:16

axios making sure that i just want to use single quotes

45:21

again that is a preference you don't have to and now this code should work and i'm just going to once again switch this to a const and get rid of any

45:29

semi and again changes to an arrow function

45:34

you can also use async and a way it is totally up to you i just copied this so there's less work for us to do

45:42

great so now that we have that let's go ahead and save the results of this so these

45:49

are the results if we test it out so if we test out the end point this is

45:56

what the result should look like so this is an array of items this is good it's

46:01

good that's an array or make it a lot easier for us so once we get the results

46:06

back so the response data that should be an array that we can work with

46:12

so let's go ahead and work with it so once again here is the array and let's

46:19

save this as something i'm going to say this is articles so this is where we use you state again i'm going to go const

46:26

articles set articles and i'm going to use

46:33

use state and set this as null this time and let's go ahead and make sure we use

46:39

state as imported from reaction you can use it and now the response data i'm going to

46:45

just use set articles to set articles to be the array

46:52

which is response data so response data will come back with the array as we just saw in rapid api response data

47:02

great so let's check it out let's see if that is indeed bringing back our articles

47:12

and wonderful an array of all the articles so now we're going to do some more mapping

47:18

so just in here in the news feed well what do i want to happen i think that we

47:25

should just in here let's perhaps also give this an h2 tag this time of news

47:33

feed and then well let's map each news article

47:39

there is a lot of articles so what we can do is just get the first i don't know first 20 articles or

47:46

something first first let's just do first seven so i would get the articles

47:56

array and i'm going to use the javascript method of slice and just get

48:01

the first oops seven so that's how you do it that's how you get the first seven items of an

48:07

array and i just want to check this exists first because obviously it might not exist on the first render so if it

48:14

exists i want to save this as first seven articles

48:24

and once we have those first seven articles well this is the array that i want to map onto something and i think

48:31

we can just map this onto a p tag just like so

48:37

so let's get our curly braces up again and i'm getting

48:43

the first seven used articles and if they exist i want to then

48:49

map that onto the p tag okay so for each article so for each

48:57

article that exists in the first seven articles i want to

49:03

use some parentheses just print out the article

49:08

let's have a look i want to print out the article title so article dot title so let's get

49:16

the article title just like so and there we go

49:23

once again we will get an error as we have not passed through the key but at least we're getting our news feature up

49:30

this is looking good i want to limit the amount of re-renders because obviously that's going to

49:36

count towards our 300 so let's just keep that in mind

49:42

and then i do underscore index and give the p tag a key or we can actually which

49:50

might be a better thing to do we can wrap this in a div itself so wrap the p tag and a div

50:00

so that we can give each div some styling if we wish and let's give this the key of

50:06

underscore index just like so and perhaps maybe let's space this out so it's a bit more readable

50:15

and we can also because we see this comes back with an article

50:21

title and an article url i can now use that url to wrap the p tag in it so if i

50:29

go a and then just whack the p tag in there

50:36

and give this an href of oops

50:42

the article url or how is it spot here yes url that

50:47

should wrap each of them in a url so that we can click this and go

50:53

to the news article to read about it instead grace i'm really happy with how

51:01

this is looking so of course please feel free to use

51:07

whatever news feed you wish this is just the first one that i came across on rapid api there are so so many to choose

51:14

from so this is looking good this is pretty much all i want to

51:20

do the next thing that i want to talk to you about is storing your rapid api keys safely in a

51:29

way that will prevent other people from taking them from your github okay so that is what we are going to do

51:35

now and i'm going to finish with some styling and refactoring and just checking everything works properly

51:42

so to store this we need to store our rapid api key in a dot env file and that

51:48

dot env file is in the root of your project it's on the same level as the package.json and i'm just going to

51:53

create a dot env file and then in here i'm going to store this we don't need to

51:59

specify this as a string that is implied and let's call this rapid api

52:05

key however to use this in the react app i

52:11

also need to append react app to it just like so so that will now

52:17

work so now all i need to do is grab this and i need to use

52:22

process env in order to get the key from my.env file and then just paste that

52:30

i'm going to do so as well for the

52:36

currency converter get request and again it's the same key so just like

52:41

that and now we need to restart don't forget to restart the app so i'm going to stop and re-run

52:48

okay so again this is now kept safe in a emv file that seems to be working just as

52:56

intended that is good and then i also need to add this to the dot ignore so

53:01

that it doesn't get uploaded onto github by mistake and don't forget that even

53:06

though we are storing this in a git ignore and we are preventing this to being uploaded onto github

53:13

technically this is not super safe the only way to really keep your secret safe

53:18

is to build up a back end which we will not be doing in this tutorial however if you do want to check that out please do

53:25

i do have some videos on this this is just for your own demo purposes for projects to get hired okay this is not

53:32

how you would do this in real life so you can either choose to just save this as a personal project or watch some

53:39

tutorials of mine on node.js express and so on but just to prove to you that this

53:45

is still viewable if i go to sources then go to static

53:50

and then go to main chunk and search for rapid api

53:55

you will see the key is showing up okay it's being bundled up and we don't see process e

54:02

and v react app anymore we actually see the string itself so that's just something that you should know people

54:08

could still find this uh especially to the more trained eyes so keep that in

54:14

mind great now this is all looking fine there is

54:20

some styling one thing that i would like to do however because as we can see if i

54:25

change this everything is changing here and if i convert this

54:33

there we go we get the exchange rate from ethereum to us dollars however if we start messing around with this

54:38

obviously i don't expect that to change but this is no longer the correct exchange rate i only want to pass

54:44

through the chosen currency the primary and the secondary

54:50

one so i'm going to show you how to fix this i am doing this on the fly though so please bear with me this is not

54:57

something i pre-prepared but the way i would do this is that i would say this to state so again you

55:03

will see here that we are saving the exchange rate well the exchange rate is the only thing that we want to pass

55:09

through into the exchange rate here so there is two ways i can do this the simple way is for me just to simply set

55:19

set primary currency

55:26

set primary currency exchanged maybe let's call it like that

55:33

and pass through the chosen primary currency and then create

55:40

another use state so this time it's going to be set

55:46

primary currency exchanged and primary currency exchanged

55:54

and then do the same for the secondary currency set secondary

56:01

currency exchanged and then secondary currency exchanged so now we can

56:08

essentially set the currency that we want to pass on to

56:14

our exchange rate component chosen secondary currency

56:20

so instead of this so instead of the chosen private

56:26

currency i'm passing through the set one and same for here so secondary

56:36

just like so okay

56:41

so at the moment it's now of course we should probably change this to be the default which is btc

56:53

okay so now when we choose one of these let's go bitcoin to us dollar

56:59

do one convert that will change and if i change this now that will not change again so that

57:06

is one way to do it uh again there's better ways to do it my

57:11

suggestion would be to change this all into one thing and just save all of this as

57:17

an object just because we're not using this for anything else apart from passing into here and i will

57:24

just look a lot neater so you can keep it like this or of course you can make this an object maybe

57:31

let's make an object so const exchange to exchange

57:38

or exchanged data let's call it

57:44

data changed data once again i am doing this

57:51

on the fly exchanged which is why it's taking me a while to think of how i should call these

57:58

use state and then i'm going to have to set this

58:03

as something i'm going to set this as

58:08

primary currency

58:17

btc secondary

58:22

currency btc and then the exchange rate

58:30

as serif now so that is the object that i want to pass and i'm going to use set

58:36

data

58:42

right here to comment that out

58:47

set exchange data i'm going to open this up and once again i'm just going to have the same

58:55

structure that i did here and this time exchange rate is going to

59:01

be this i'm going to copy that and this is going to be the

59:08

chosen primary currency and this is going to be the chosen second degree currency which

59:14

means i don't need this anymore because i'm just dealing with everything in this one object so that should now be saved

59:20

to exchanged data we can console log this out

59:27

and i'm simply just going to pass through the exchange data exchange data get rid of these

59:34

go back to the exchange rate simply just pass through the exchange data

59:39

and now i can get the exchange data exchange rate exchange data chosen private currency and the

59:46

exchange data chosen secondary currency so let's hope that has worked

59:52

exchange rate is not defined

59:59

just gonna get rid of these for now

60:05

there we go oops that should be primary currency

60:16

and this should be secondary currency

60:22

exchange rate is exchange rate

60:28

and let's check it out so now if i go bitcoin to

60:34

us dollars convert okay so that is changing it will not

60:40

change this so that is good however the exchange rate is not showing up why is that

60:46

exchange rate let's console log the

60:52

exchange data

61:01

convert so the exchange rate is being passed through i can see that uh it's because

61:08

it's a capital e so let's go ahead and change this here exchange rate

61:15

exchange rate wonderful so let's just make sure that

61:22

that is the same too and there we go this should be fine again

61:28

thank you for bearing with me as i fix this on the fly converge wonderful

61:33

so we have done it we have now built our currency converter it converts currencies it only passes through the

61:39

set currency and it won't change anything if i select other ones so just like so

61:45

not all of these convert to each other by the way you would have to do some more research on that and if i press the

61:50

button the currency version will go through great

61:55

so now just some final styling and we're finished so i'm going to go back to here

62:04

and we have our app our newsfeed i actually don't really like this color let's go ahead and change this i'm going

62:09

to use rgb for this tutorial sometimes is use hex and sometimes i don't uh i

62:16

know this color is nice so this is something that i pre-prepared in terms of styling because i don't really like

62:22

to spend too much time on the styling if you know me i feel like i like to focus on the javascript

62:30

options a little bit more so let's give it some margin let's also give it some box shadow

62:39

uh so if you know how to use box shadow this should be familiar too sorry that i am not explaining this very much much

62:46

once again i don't really like to focus too much on styling aspects in my tutorials

62:56

and finally i'm also going to give this a max width so the news feed itself of 300 pixels as it is a bit intimidating

63:02

at the moment it's taking up too much space i only want it to take up this much space great so there we go and that's the

63:08

currency converter well i'm actually also going to change this to rgb and this is a color that i picked out

63:14

earlier so they're all going to be quite light initial colors let's also give this some padding of 10 pixels

63:21

margin 5 pixels just to space all the boxes out from each other and once again i'm just going to copy this box shadow

63:28

styling and i'm also going to make all the text aligned to the center so that has now

63:34

changed our currency converter to look like this one more thing to do and that is style with green exchange rate so

63:41

let's find the exchange rate and once again let's change this to be an rgb color and i'm going to change this to

63:48

the 2 2 1 2 3 2 2 1 and let's again give it some padding so

63:55

padding 20 pixels margin top

64:03

10 pixels and then box shadow

64:09

again just let's give it that great so that is already looking a lot cooler

64:16

i think uh let's also make sure that it's in the center so i'm going to do that now and maybe

64:23

let's style the button a bit

64:30

so button order none

64:36

float right because i want it to go to the right

64:42

let's give it some margin i love a bit of a margin font family

64:50

now the font family should be applied from the body i think so perhaps let's just relieve that

64:56

that is looking fine uh however on the button hover

65:02

so as soon as we hover over the button i want the background color to change

65:08

let's start off with coral but let's maybe just change it around a little bit

65:14

to also be rgb a

65:21

okay well let's keep it coral for now and i can always replace it later

65:30

so now when we hover over it changes color let's also space this out a little bit so

65:36

let's perhaps do that now i'm going to get the input

65:43

box

65:49

give it a background color rgb

65:54

two one eight two two seven two three eight

66:01

padding 30 pixels border radius i like a bit of border

66:07

radius 210 pixels and once again some

66:13

box shadow now this is shaping up much nicer now that button's in here and this is

66:18

looking a lot slicker a few more things to do i want to add some assignment to the select and the input

66:24

so i can do so like this i can grab the input and the select

66:32

and just give it a border of none okay so i've got rid of the border of that

66:38

and i think this is looking good

66:43

i'm really enjoying how this is looking perhaps let's also add some border to this here so border radius

66:50

on the exchange rate should also be 10 and wonderful and one last thing i did

66:57

say i want to center this so let's go ahead and do that so change that to an f that should have

67:03

been an f from the beginning so now these two are once again on top of each other i want them to be next to each

67:09

other so all i'm gonna do is go into here and in the app i'm going to put these

67:15

in another div i'm just going to get these cut them and give this a class

67:21

name of app

67:26

wrapper grab the app wrapper

67:33

and just once again to display flex so now they're next to each other and

67:39

one final touch i'm just going to add a title for our apps on h1 tag and let's call this crypto

67:46

dashboard and wonderful we have now finished our

67:51

crypto dashboard i hope you've learned something new i hope you can take this project and share it with your potential

67:57

employers really demonstrating that you know how to work with apis as we work with two and demonstrating your react

68:04

skills as well as demonstrating that you know about the safety of api keys thanks very much and i'll see you soon