Skip to content

Commit

Permalink
rename others sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeeppy committed May 1, 2023
1 parent a49fdf6 commit 65c38f5
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 56 deletions.
24 changes: 0 additions & 24 deletions session25/bitcoin-prix/script.js

This file was deleted.

12 changes: 0 additions & 12 deletions session25/n/index.html

This file was deleted.

20 changes: 0 additions & 20 deletions session25/n/script.js

This file was deleted.

Empty file removed session25/n/style.css
Empty file.
30 changes: 30 additions & 0 deletions session29/axios-get/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!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">
<title>Document</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" />
<link rel="stylesheet" href="style.css" />
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
<div class="container">

<div class="row justify-content-center">

<div class="col-md-8">
<h1 class="text-center mt-5">Bitcoin Price</h1>

<div id="price" class="text-center">
<span id="price_label">xxxx.xx</span>
</div>
</div>

</div>

</div>
<script src="script.js"></script>
</body>
</html>
13 changes: 13 additions & 0 deletions session29/axios-get/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const url = 'https://blockchain.info/ticker';

async function recupererPrix() {
axios.get(url)
.then(function(donnees) {
document.querySelector("#price_label").textContent = donnees.data.EUR.last;
})
.catch(function(erreur) {
alert('Un problème est survenu');
})
}

setInterval(recupererPrix, 1000);
File renamed without changes.
17 changes: 17 additions & 0 deletions session29/axios-post/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const url = 'https://lesoublisdelinfo.com/api.php';

const axiosInstance = axios.create({
headers: {
'Content-Type': 'applicaiton/x-www-form-urlencoded'
}
});

axiosInstance.post(url, new URLSearchParams({
prenom: 'Steve'
}))
.then(function(donnees) {
console.log(donnees);
})
.catch(function(erreur) {
console.log(erreur);
})
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ <h1 class="text-center mt-5">Bitcoin Price</h1>
</div>

</div>

<script src="script.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions session29/fetch-get/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const url = 'https://blockchain.info/ticker';

async function recupererPrix() {
const requete = await fetch(url, {
method: 'GET'
});

if (!requete.ok) {
alert('Un problème est survenu');
} else {
let donnees = await requete.json();
document.querySelector("#price_label").textContent = donnees.EUR.last;
}
}

setInterval(recupererPrix, 1000);
7 changes: 7 additions & 0 deletions session29/fetch-get/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
h1 {
color: #272343;
}

#price {
font-size: 4em;
}
47 changes: 47 additions & 0 deletions session29/fetch-post/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const url = 'https://lesoublisdelinfo.com/api.php';

async function envoyerPrenom(prenom) {
const requete = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
prenom
})
});

if (!requete.ok) {
alert('Un problème est survenu');
} else {
const donnees = await requete.json();
console.log(donnees);
}
}

envoyerPrenom('Teddy');

// let requete = new XMLHttpRequest();

// // Get
// // requete.open('GET', url);
// // requete.responseType = 'json';
// // requete.send();

// // Post
// requete.open('POST', url);
// requete.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// requete.responseType = 'json';
// requete.send('prenom=John');

// requete.onload = function() {
// if (requete.readyState === XMLHttpRequest.DONE) {
// if (requete.status === 200) {
// let reponse = requete.response;
// console.log(reponse);
// }
// else {
// alert('Un problème est intervenu, merci de revenir plus tard.');
// }
// }
// }

0 comments on commit 65c38f5

Please sign in to comment.