PHP 8.6.0 RC5 available for testing
+add a note

User Contributed Notes 1 note

up
0
baba at bibi dot com
1 day ago
// QUESTION 7 API JS // // Seulement 75 %

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="style.css">
        <title>API</title>
    </head>
    <body>
        <h1>Use API</h1>
        <button onclick="get_all_facts();">Get ChatGPT's Fun Facts</button>
      
        <div id='results'>
        </div>

        <script src="./Q7-1.js">
        </script>

        <script>
        
            function set_vote(id, up) {
                let data = {up : up};
              fetch('https://code.estia.fr/webdyn/api/facts/{id}/score',
               {
                   method: 'PUT',
                   headers: {       
                     'Content-Type': 'application/json'                                  // tell the server we are sending JSON
                   },
                   body: JSON.stringify({up: up})  
               }
               )
               .then(response => response.json())
               .then(
                   data => {
                       get_all_facts();
                   }
                );
          }
        </script>
    </body>
</html>
To Top