Initial QuestionGraph library and documentation
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import type { QuestionnaireSaveHandler } from "../../lib";
|
||||
|
||||
export const saveDraft: QuestionnaireSaveHandler = async request => {
|
||||
const response = await fetch("/api/claims/current/draft", {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"If-Match": JSON.stringify(request.revision),
|
||||
},
|
||||
body: JSON.stringify(request),
|
||||
});
|
||||
|
||||
// Reject failures so the renderer stays on the page and allows a retry.
|
||||
if (!response.ok) throw new Error("Could not save your answers.");
|
||||
|
||||
// The server returns { revision: number }.
|
||||
return response.json();
|
||||
};
|
||||
Reference in New Issue
Block a user