Last active
November 19, 2021 05:58
-
-
Save ShariqT/5e95170c96d034e184faa1270a6ee932 to your computer and use it in GitHub Desktop.
CreatePostcard.vue
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
async function handleSubmit() { | |
const body = { | |
toAddress: { ...toAddress.value }, | |
fromAddress: { ...fromAddress.value }, | |
frontTemplate: frontTemplate.value, | |
backTemplate: backTemplate.value | |
} | |
error.value = "" | |
success.value = false | |
loading.value = true | |
const response = await fetch("http://localhost:3030/postcard/create", { | |
method: "POST", | |
body: JSON.stringify(body), | |
headers: { | |
"Content-Type": "application/json" | |
} | |
}) | |
const data = await response.json() | |
if (!data.success) { | |
loading.value = false | |
error.value = data.error_message | |
return | |
} | |
setTimeout(function(){ | |
loading.value = false | |
backThumbnail.value = data.postcard.thumbnails[1].medium | |
frontThumbnail.value = data.postcard.thumbnails[0].medium | |
success.value = true | |
}, 4000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment