@friendofsvelte/django-kit
Advanced tools
Comparing version 0.0.1-dev.117 to 0.0.1-dev.118
import { type Actions } from '@sveltejs/kit'; | ||
export type BASE_METHOD = 'GET' | 'POST' | 'PUT' | 'DELETE'; | ||
export type NamedActionInfo = { | ||
name: string; | ||
method: 'GET' | 'POST' | 'PUT' | 'DELETE'; | ||
method: BASE_METHOD; | ||
allow_cookies?: boolean; | ||
@@ -9,3 +10,3 @@ }; | ||
path: string; | ||
method: 'GET' | 'POST'; | ||
method: BASE_METHOD; | ||
allow_cookies?: boolean; | ||
@@ -12,0 +13,0 @@ }; |
@@ -40,2 +40,5 @@ import { fail, redirect } from '@sveltejs/kit'; | ||
} | ||
if (response.status === 204) { | ||
return; | ||
} | ||
data = await response.json(); | ||
@@ -93,11 +96,12 @@ } | ||
[proxy_action.path]: async (event) => { | ||
const suffix = event.url.searchParams.get("_sfx") || ""; // path suffix | ||
try { | ||
const form_data = await event.request.formData(); | ||
let url = `${opt_.django_base_api}/${proxy_action.path}`; | ||
let url = `${opt_.django_base_api}/${proxy_action.path}${suffix}`; | ||
let options = { method: proxy_action.method }; | ||
if (proxy_action.method === 'GET') { | ||
url = `${url}?${new URLSearchParams(form_data).toString()}`; | ||
if (proxy_action.method === "POST" || proxy_action.method === "PUT") { | ||
options = { ...options, body: form_data }; | ||
} | ||
else { | ||
options = { ...options, body: form_data }; | ||
url = `${url}?${new URLSearchParams(form_data).toString()}`; | ||
} | ||
@@ -104,0 +108,0 @@ const response = await event.fetch(url, options); |
{ | ||
"name": "@friendofsvelte/django-kit", | ||
"version": "0.0.1-dev.117", | ||
"version": "0.0.1-dev.118", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "dev": "vite dev", |
23697
471