Created
February 7, 2019 08:56
-
-
Save omosehin/dd9611b5be67cc7d8d089a85372d48bf to your computer and use it in GitHub Desktop.
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
const{ voucherType, category, expirationDate,startDate,charset, amount, length, prefix, pattern, postfix,additionalInfo,separator,lengthPattern} = this.state.newUser; | |
const userData = { | |
voucherType, category, expirationDate,startDate,charset, amount, length, prefix, pattern, postfix,additionalInfo,separator,lengthPattern | |
} | |
console.log(userData); | |
const voucherData = JSON.stringify(userData) | |
console.log(voucherData); | |
// let user = JSON.parse(sessionStorage.getItem('data')); | |
// const token = user.data.id; | |
const headers = { | |
"Content-Type": "application/json", | |
"Authorization": "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqb3lAZ21haWwuY29tIiwiaWF0IjoxNTQ5NTE3MDUxLCJleHAiOjE1NDk1MTgwNTF9.lnwYO5kVuLD-SyyRTYt_iVmBprmIbrDDuMQ7hYyQSPMexJJZcwnUp1m-k46FxxoOihp2P7Y-micDKp1_IQOSyw" | |
// "Authorization": `Bearer ${token}` | |
} | |
axios.post(`http://172.20.20.17:8091/api/voucher/value/single/create`,voucherData, {"headers": headers}) | |
.then((res)=>{ | |
console.log(res); | |
if(res.data.code === "CREATED"){ | |
alert("Voucher Created Succesfully") | |
// document.getElementById("submitBtn").innerHTML = "Submit" | |
} | |
else if(res.code === 409){ | |
alert(">>>>>>>>>>"); | |
} | |
}) | |
.catch((error) => { | |
// document.getElementById("submitBtn").innerHTML = "Submit" | |
alert("Voucher Creation Failed") | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment