text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
different currency in order to get the | 6,422.04 | 4.3 |
all to work so now here's what we can do | 6,423.55 | 5.58 |
if I open up currency dot HTML again I | 6,426.34 | 5.219 |
now see a form where I can type in a | 6,429.13 | 4.259 |
currency I can type in something like | 6,431.559 | 4.35 |
the Europe for example press convert and | 6,433.389 | 4.381 |
I see alright one u.s. dollar equal to | 6,435.909 | 5.58 |
0.9 0.0 something like the pound press | 6,437.77 | 6.03 |
convert one u.s. dollar equal to 0.77 | 6,441.489 | 4.98 |
one pounds I type in the Japanese yen | 6,443.8 | 4.859 |
one u.s. dollar is equal to 109 point | 6,446.469 | 4.351 |
eight five two Japanese yen and all of | 6,448.659 | 3.54 |
this is happening where every time I | 6,450.82 | 3.21 |
submit the form it's making yet another | 6,452.199 | 4.261 |
request so if the exchange rates happen | 6,454.03 | 3.99 |
to change in between when I submit the | 6,456.46 | 3.599 |
form the next time I submit the form I | 6,458.02 | 3.51 |
will be getting the latest exchange | 6,460.059 | 3.361 |
rates according to that exchange rates | 6,461.53 | 4.08 |
API and the results are going to come | 6,463.42 | 3.989 |
back here and of course if I type in a | 6,465.61 | 3.719 |
currency that doesn't exist I type in | 6,467.409 | 3.81 |
something like foo for example and press | 6,469.329 | 4.261 |
convert invalid currency so it's going | 6,471.219 | 4.051 |
to report back to me that it wasn't able | 6,473.59 | 3.569 |
to find that currency and so it tells me | 6,475.27 | 3.21 |
that I need to type in something valid | 6,477.159 | 2.94 |
and so I can type in something valid | 6,478.48 | 3.84 |
maybe I try just US dollars itself it | 6,480.099 | 5.011 |
tells me one u.s. dollar is equal to one | 6,482.32 | 4.68 |
US dollar exactly what I would expect it | 6,485.11 | 4.469 |
to be now there are a couple of | 6,487 | 4.11 |
optimizations and improvements that we | 6,489.579 | 3.421 |
can make here one is that I can search | 6,491.11 | 3.81 |
for euros right now with EU our press | 6,493 | 4.05 |
convert but if I search for euros in | 6,494.92 | 4.71 |
lower case for example it turns out it | 6,497.05 | 4.2 |
thinks that's an invalid currency and | 6,499.63 | 4.77 |
the reason why is because if you look at | 6,501.25 | 4.8 |
the data that comes back to me from the | 6,504.4 | 3.36 |
API this is the data that I get back | 6,506.05 | 4.109 |
from the exchange rates API what you'll | 6,507.76 | 4.319 |
notice is that all of the currencies are | 6,510.159 | 3.841 |
all in capital letters that are all | 6,512.079 | 3.451 |
capital letters all capital letters | 6,514 | 3.599 |
which means the only keys that I'm | 6,515.53 | 4.379 |
allowed to access are in fact those that | 6,517.599 | 3.691 |
have capital letters in them because | 6,519.909 | 3.21 |
these are the only keys that this API | 6,521.29 | 4.53 |
makes available to me so if I want to | 6,523.119 | 4.921 |
convert between US dollars and euros | 6,525.82 | 4.589 |
lowercase what I might want to do is | 6,528.04 | 4.92 |
first take the currency the thing the | 6,530.409 | 6.54 |
user typed in and first just call to | 6,532.96 | 6 |
uppercase on it which is a JavaScript | 6,536.949 | 3.42 |
function that takes a string and | 6,538.96 | 3.449 |
converts it Dabra case I'd like to take | 6,540.369 | 3.931 |
whatever the user typed in and now just | 6,542.409 | 3.931 |
first convert it to uppercase that way | 6,544.3 | 4.77 |
if I go back here I can type in Euro | 6,546.34 | 5.219 |
lowercase press convert and I'm still | 6,549.07 | 4.94 |
able to get the correct conversion rate | 6,551.559 | 4.861 |
the other thing that we won't noticeably | 6,554.01 | 3.34 |
notice the difference with | 6,556.42 | 3.6 |
is that right now I'm assuming that all | 6,557.35 | 4.56 |
of this is going to go successfully that | 6,560.02 | 3.3 |
we're gonna successfully be able to make | 6,561.91 | 3.3 |
a web request will successfully convert | 6,563.32 | 3.72 |
the response back to Jason but you never | 6,565.21 | 3.93 |
know an API could go down the API could | 6,567.04 | 3.84 |
change and do something unexpected and | 6,569.14 | 3.42 |
so anytime you're dealing with these | 6,570.88 | 3.15 |
types of promises where you fetch | 6,572.56 | 3.45 |
something and say then do this then do | 6,574.03 | 4.53 |
that it can often be a good idea to add | 6,576.01 | 6.24 |
one last case which is a catch case that | 6,578.56 | 5.34 |
basically says what should you do if | 6,582.25 | 4.11 |
something goes wrong so I can say catch | 6,583.9 | 4.2 |
the error and what I can just do is say | 6,586.36 | 6.3 |
like console dot log error and then log | 6,588.1 | 6.18 |
the error there and all that's really | 6,592.66 | 3.87 |
saying is that if anything above goes | 6,594.28 | 3.96 |
wrong with the fetching and trying to | 6,596.53 | 3.72 |
process the response it's gonna catch | 6,598.24 | 4.17 |
the error and then we'll just like print | 6,600.25 | 3.96 |
out to the console that something went | 6,602.41 | 3.72 |
wrong some error message happened and so | 6,604.21 | 3.72 |
that can be a helpful nice to have just | 6,606.13 | 3.39 |
to make sure that when things crash they | 6,607.93 | 3.09 |
crash in a predictable way that you're | 6,609.52 | 3.45 |
able to see exactly what the error is | 6,611.02 | 4.44 |
and just by looking inside the | 6,612.97 | 4.68 |
JavaScript console and so now we have a | 6,615.46 | 4.5 |
fully working web page that is able to | 6,617.65 | 4.71 |
communicate with an external API that is | 6,619.96 | 4.53 |
able to ask for information from another | 6,622.36 | 3.27 |
service on the Internet | 6,624.49 | 3.27 |
use those results and put them back into | 6,625.63 | 4.29 |
the page really just going to show the | 6,627.76 | 4.02 |
power now that we get by taking | 6,629.92 | 4.32 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.