Coding Challenge #25 JavaScript ? | Lecture 240
Asynchronous JavaScript: Promises, Async_Await, and AJAX
LECTURE: 240 Coding Challenge #25 | JavaScript ?
Coding Challenge #25 | JavaScript ?
Coding Challenege Pdf Link:
? https://drive.google.com/file/d/1zdx9--KSMwRT1XfyePBpfUURWEnXs1tc/view?usp=sharing
In this challenge you will build a function *'whereAmI'* which renders a country *only* based on GPS coordinates. For that, you will use a second API to geocode coordinates. So in this challenge, you’ll use an API on your own for the first time ?
*Your tasks:*
*PART 1*
1. Create a function *'whereAmI'* which takes as inputs a latitude value *('lat')* and a longitude value *('lng')* (these are GPS coordinates, examples are in test data below).
2. Do *“reverse geocoding”* of the provided coordinates. Reverse geocoding means to convert coordinates to a meaningful location, like a city and country name.Use this API to do reverse geocoding : ? https://geocode.xyz/api. The AJAX callwill be done to a URL with this format: ? https://geocode.xyz/52.508,13.381?geoit=json. Use the fetch API and promises to get the data. Do *not* use the *'getJSON'* function we created, that is cheating ?
3. Once you have the data, take a look at it in the console to see all the attributes that you received about the provided location. Then, using this data, log a message like this to the console: *“You are in Berlin, Germany”*
4. Chain a .catch method to the end of the promise chain and log errors to the console
5. This API allows you to make only 3 requests per second. If you reload fast, you will get this error with code *403*. This is an error with the request. Remember, *fetch()* does *not* reject the promise in this case. So create an error to reject the promise yourself, with a meaningful error message
*PART 2*
6. Now it's time to use the received data to render a country. So take the relevant attribute from the geocoding API result, and plug it into the countries API that we have been using.
7. Render the country and catch any errors, just like we have done in the last lecture (you can even copy this code, no need to type the same code)
*Test data:*
Coordinates 1: 52.508, 13.381 (Latitude, Longitude)
Coordinates 2: 19.037, 72.873
Coordinates 3: -33.933, 18.474
GOOD LUCK ?
Like | Subscribe | Share
The Coding Classroom (⌐■_■)
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Coding Challenge #25 JavaScript ? | Lecture 240», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.