mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-03 14:37:21 +01:00
change api
This commit is contained in:
@@ -7,7 +7,7 @@ function checkStatus(res: Response) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function generatePdf(state: IDocProps) {
|
||||
export async function generatePdf(state: IDocProps): Promise<string> {
|
||||
const options = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -16,19 +16,20 @@ export async function generatePdf(state: IDocProps) {
|
||||
body: JSON.stringify(state),
|
||||
}
|
||||
|
||||
const response = await fetch('/api/pdf/generate/brief', options)
|
||||
const response = await fetch('/api/document?template=brief', options)
|
||||
checkStatus(response)
|
||||
return response.json()
|
||||
const { id } = await response.json()
|
||||
return `/api/document/${id}`
|
||||
}
|
||||
|
||||
export async function getLatest(): Promise<ILatest[]> {
|
||||
const response = await fetch('/api/pdf/latest')
|
||||
const response = await fetch('/api/document/latest')
|
||||
checkStatus(response)
|
||||
return response.json()
|
||||
}
|
||||
|
||||
export async function removeLatest(item: { id: string }) {
|
||||
const response = await fetch(`/api/pdf/${item.id}`, { method: 'DELETE' })
|
||||
const response = await fetch(`/api/document/${item.id}`, { method: 'DELETE' })
|
||||
checkStatus(response)
|
||||
return response
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user