Skip to content

Instantly share code, notes, and snippets.

@ShariqT
Last active November 19, 2021 05:58
Show Gist options
  • Save ShariqT/5e95170c96d034e184faa1270a6ee932 to your computer and use it in GitHub Desktop.
Save ShariqT/5e95170c96d034e184faa1270a6ee932 to your computer and use it in GitHub Desktop.
CreatePostcard.vue
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