Last active
February 6, 2024 07:59
-
-
Save matthieua/1a5593c09ac1d63668b9dd7f10c9d330 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | |
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> | |
<title>OpenWeather API</title> | |
<style> | |
body { | |
background: #f6f6f6; | |
} | |
h1 { | |
color: #6443ea; | |
font-family: "PT Mono"; | |
text-align: center; | |
} | |
img { | |
display: block; | |
margin: 0 auto; | |
width: 90%; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>🖲 AJAX</h1> | |
<img | |
src="https://paper-attachments.dropbox.com/s_A95344764D52AA21419095E524C2218D68BF719E44B29F7D8A2A3E2647B9B8AF_1560193261406_image.png" | |
alt="API" | |
/> | |
<script> | |
function displayUsername(response) { | |
let h1 = document.querySelector("h1"); | |
h1.innerHTML = `Hey ${response.data[0].username}`; | |
} | |
let apiUrl = "https://jsonplaceholder.typicode.com/users/"; | |
axios.get(apiUrl).then(displayUsername); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This option no longer seems to be available on the axios page. You should update your content to reflect this.