Created
June 20, 2020 10:04
-
-
Save Alphajeez96/92bb7ab01c776e03fd2ff05c0e3737e9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let e = document.getElementById("ddlViewBy"); | |
let provider = e.options[e.selectedIndex].value; | |
let number = document.getElementById('number').value; | |
let amount = document.getElementById('amount').value; | |
let secret = 'uvjqzm5xl6bw ' | |
const data = { | |
code: this.provider, | |
PhoneNumber: this.number, | |
Amount: this.amount, | |
SecretKey: this.secret, | |
}; | |
const performPostRequest = () => { | |
fetch('https://cors-anywhere.herokuapp.com/https://sandbox.wallets.africa/bills/airtime/purchase', { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
'Authorization': ' Bearer uvjqzm5xl6bw', | |
'redirect': 'follow' | |
}, | |
body: JSON.stringify(data), | |
}) | |
.then(response => response.json()) | |
.then(data => { | |
console.log('Success:', data); | |
}) | |
.catch((error) => { | |
console.error('Error:', error); | |
}); | |
event.preventDefault(); | |
} | |
// document.getElementById('formish').addEventListener('submit', performPostRequest); | |
const closeModal = () => { | |
// document.getElementById("test").style.display = "hidden"; | |
// document.getElementsByClassName("test").remove(); | |
form.close(); | |
} | |
const log = document.getElementById('log'); | |
const form = document.getElementById('form'); | |
form.addEventListener('submit', performPostRequest); | |
form.addEventListener('submit', closeModal); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment