Skip to content

Instantly share code, notes, and snippets.

@oprietop
Created December 4, 2022 09:38
Show Gist options
  • Save oprietop/91e35d8eade71b65e0d3551f5af867c3 to your computer and use it in GitHub Desktop.
Save oprietop/91e35d8eade71b65e0d3551f5af867c3 to your computer and use it in GitHub Desktop.
async fetch example
<!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