api_test.html (867B)
1 <html> 2 <head> 3 4 </head> 5 <body> 6 <script> 7 8 // Create an object with the data to send 9 const data = { 10 11 token: '3jvl7yb5sRr80s6lTdeOyxV9VTQZkCPRp7bKOWKFWxfL2vhsU4Hhpgcmz9qe0zEk' 12 }; 13 14 // Send a POST request to the PHP endpoint 15 fetch('/api/', { 16 method: 'POST', 17 headers: { 18 'Content-Type': 'application/json', 19 'Authorization': data.token 20 }, 21 body: JSON.stringify(data) 22 }) 23 .then(response => response.json()) 24 .then(responseData => { 25 // Handle the response data from the PHP endpoint 26 console.log(responseData); 27 }) 28 .catch(error => { 29 // Handle any errors that occurred during the request 30 console.error(error); 31 }); 32 33 </script> 34 </body> 35 36 </html>