Last active
February 16, 2021 14:21
-
-
Save yostane/ca956b8ce35ce7721b74569b71e972bf to your computer and use it in GitHub Desktop.
webapp fiels
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
async function retreiveNumbers() { | |
const response = await fetch("/random"); | |
const numbers = await response.json(); | |
// suite du code | |
} |
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 http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="/css/style.css"> <!-- car public es servi sur /--> | |
<script src="/js/script.js"></script> | |
<title>test</title> | |
</head> | |
<!-- squelette ou app shell --> | |
<body> | |
<h1 id="mainHeader">test</h1> | |
<div id="content"></div> | |
<img src="/rondoudou.gif" alt="rondoudou" /> | |
</body> | |
</html> |
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
// DOMContentLoaded => au chargement de la page | |
document.addEventListener("DOMContentLoaded", async () => { | |
const element = document.getElementById("mainHeader"); | |
element.style.color = "pink"; | |
// fetch nécessite un await | |
// présence d'au moins un await -> mettre async avec les () | |
// récup des données du serveur | |
const response = await fetch("/test_send"); | |
const text = await response.text(); | |
// on met la donnée dans le corps de la balise qui a l'id->"content" | |
const contentElement = document.getElementById("content"); | |
contentElement.innerHTML = text; | |
}); |
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
h1 { | |
border: 2px solid rgb(95, 95, 219); | |
background-color: purple; | |
color: black; | |
border-radius: 10px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment