change api

This commit is contained in:
Thomas Ruoff
2021-03-06 23:52:55 +01:00
parent 2721e65f09
commit fa85d36924
5 changed files with 21 additions and 23 deletions

View File

@@ -58,22 +58,19 @@ export default function App() {
window.location.reload()
}
const _onGenerate = () => {
const _onGenerate = async () => {
setPdfIsLoading(true)
setPdfError(null)
generatePdf(options)
.then((data) => {
const { id } = data
setPdfIsLoading(false)
setPdfUrl(`/api/pdf/${id}`)
})
.catch((error) => {
setPdfIsLoading(false)
setPdfError(error.message)
setPdfUrl(null)
})
try {
const url = await generatePdf(options)
setPdfIsLoading(false)
setPdfUrl(url)
} catch (error) {
setPdfIsLoading(false)
setPdfError(error.message)
setPdfUrl(null)
}
}
return (