Split FORM and regular POST
This commit is contained in:
parent
4d04529ae2
commit
adc6e0a2cf
@ -9,7 +9,7 @@ export function GET(path: string) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function POST(path: string, body: FormData | string | null) {
|
export function FORM(path: string, body: FormData) {
|
||||||
const sessionStore = useSessionStore();
|
const sessionStore = useSessionStore();
|
||||||
return fetch(BASE_URL + path, {
|
return fetch(BASE_URL + path, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -19,6 +19,18 @@ export function POST(path: string, body: FormData | string | null) {
|
|||||||
body: body,
|
body: body,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function POST(path: string, body: string | null) {
|
||||||
|
const sessionStore = useSessionStore();
|
||||||
|
return fetch(BASE_URL + path, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
...sessionStore.AuthHeaders,
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: body,
|
||||||
|
});
|
||||||
|
}
|
||||||
export function DELETE(path: string) {
|
export function DELETE(path: string) {
|
||||||
const sessionStore = useSessionStore();
|
const sessionStore = useSessionStore();
|
||||||
return fetch(BASE_URL + path, {
|
return fetch(BASE_URL + path, {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { GET, POST } from "../api";
|
import { GET, POST, FORM } from "../api";
|
||||||
import { useAccountStore } from "./budget-account";
|
import { useAccountStore } from "./budget-account";
|
||||||
import { useCategoryStore } from "./category";
|
import { useCategoryStore } from "./category";
|
||||||
import { Budget, useSessionStore } from "./session";
|
import { Budget, useSessionStore } from "./session";
|
||||||
@ -25,9 +25,9 @@ export const useBudgetsStore = defineStore("budget", {
|
|||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
ImportYNAB(formData: FormData) {
|
ImportYNAB(formData: FormData) {
|
||||||
return POST(
|
return FORM(
|
||||||
"/budget/" + this.CurrentBudgetID + "/import/ynab",
|
"/budget/" + this.CurrentBudgetID + "/import/ynab",
|
||||||
formData
|
formData,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
async NewBudget(budgetName: string): Promise<void> {
|
async NewBudget(budgetName: string): Promise<void> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user