updated index for web app
This file contains 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" dir="ltr"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hello World</title> | |
<style> | |
body { | |
background-color: #232F3E; | |
} | |
label, button { | |
color: #FF9900; | |
font-family: Arial, Helvetica, sans-serif; | |
font-size: 20px; | |
margin-left: 40px; | |
} | |
input { | |
color: #232F3E; | |
font-family: Arial, Helvetica, sans-serif; | |
font-size: 20px; | |
margin-left: 20px; | |
} | |
</style> | |
<script> | |
var callAPI = (fname, lname)=>{ | |
var myHeaders = new Headers(); | |
myHeaders.append("Content-Type", "application/json"); | |
var raw = JSON.stringify({"firstname":fname,"lastname":lname}); | |
var requestOptions = { | |
method: 'POST', | |
headers: myHeaders, | |
body: raw, | |
redirect: 'follow' | |
}; | |
fetch("api-key", requestOptions) | |
.then(response => response.text()) | |
.then(result => alert(JSON.parse(result).message)) | |
.catch(error => console.log('error', error)); | |
} | |
</script> | |
</head> | |
<body> | |
<form> | |
<label>First Name :</label> | |
<input type="text" id="fName"> | |
<label>Last Name :</label> | |
<input type="text" id="lName"> | |
<button type="button" onclick="callAPI(document.getElementById('fName').value, document.getElementById('lName').value)">Call API</button> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment