-
Notifications
You must be signed in to change notification settings - Fork 0
Homework for lection14 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
You can check this code at CodeSandbox with the link |
src/script/ui.js
Outdated
|
|
||
| //request to geocoder | ||
| export async function getCoordinates(city) { | ||
| let response = await window.fetch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем window?
src/script/ui.js
Outdated
|
|
||
| //request to weather provider | ||
| async function getWeather(lat, lon) { | ||
| let url = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
использовать шаблонную строку
src/script/ui.js
Outdated
| "%2C" + | ||
| (Number(lat) + 0.05); | ||
| iframe.src += prjConst.MAP_URL_END; | ||
| showWeather(await getWeather(lat, lon)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
обернуть в try catch
src/script/ui.js
Outdated
| let showWeather = (weather) => { | ||
| let main = weather.list[0].main; | ||
| let temp = main.temp; | ||
| if (isNaN(temp)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перенести в функцию showError
src/script/ui.js
Outdated
|
|
||
| export let createStyledElement = (tag, style, id) => { | ||
| let el = document.createElement(tag); | ||
| style !== null && (el.className = style); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style && (el.className = style);
src/script/ui.test.js
Outdated
| url = url.replace(prjConst.GEOCODER_URL_START, ""); | ||
| url = url.replace(prjConst.GEOCODER_URL_END, ""); | ||
|
|
||
| return new Promise((resolve) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.