update
This commit is contained in:
36
frontend/src/api.js
Normal file
36
frontend/src/api.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const BASE = '/api'
|
||||
|
||||
export async function fetchGuides() {
|
||||
const res = await fetch(`${BASE}/guides`)
|
||||
return res.json()
|
||||
}
|
||||
|
||||
export async function fetchGuide(id) {
|
||||
const res = await fetch(`${BASE}/guides/${id}`)
|
||||
return res.json()
|
||||
}
|
||||
|
||||
export async function createGuide(topic, format) {
|
||||
const res = await fetch(`${BASE}/guides`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ topic, format }),
|
||||
})
|
||||
return res.json()
|
||||
}
|
||||
|
||||
export async function cancelGuide(id) {
|
||||
await fetch(`${BASE}/guides/${id}/cancel`, { method: 'POST' })
|
||||
}
|
||||
|
||||
export async function deleteGuide(id) {
|
||||
await fetch(`${BASE}/guides/${id}`, { method: 'DELETE' })
|
||||
}
|
||||
|
||||
export function pdfUrl(id) {
|
||||
return `${BASE}/guides/${id}/pdf`
|
||||
}
|
||||
|
||||
export function htmlUrl(id) {
|
||||
return `${BASE}/guides/${id}/html`
|
||||
}
|
||||
Reference in New Issue
Block a user