Skip to content

Instantly share code, notes, and snippets.

@omosehin
Created February 7, 2019 08:56
Show Gist options
  • Save omosehin/dd9611b5be67cc7d8d089a85372d48bf to your computer and use it in GitHub Desktop.
Save omosehin/dd9611b5be67cc7d8d089a85372d48bf to your computer and use it in GitHub Desktop.
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