Created
December 4, 2022 09:38
-
-
Save oprietop/91e35d8eade71b65e0d3551f5af867c3 to your computer and use it in GitHub Desktop.
async fetch example
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> | |
<head> | |
<meta charset="utf-8"> | |
<title>ASD</title> | |
<script> | |
async function test() { | |
let url = 'http://jenkins/8080/job/dummy_job/buildWithParameters'; | |
let username = 'XXXXXX' | |
let token = 'XXXXXX' | |
let formData = new FormData(); | |
formData.append("ID", "666"); | |
formData.append("EMAIL", "me@foo.bar"); | |
response = await fetch( | |
url, { | |
method: 'POST', | |
headers: { | |
'Authorization': 'Basic ' + btoa(username + ":" + password), | |
}, | |
body: formData | |
} | |
); | |
document.body.innerHTML = await response.status | |
} | |
test(); | |
</script> | |
</head> | |
<body> | |
ASD | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment