Speaking of this was just bouta ask you

Speaking of this was just bouta ask... you ever run into an issue where deployed works perfect as expected but locally it will say the command worked but it did nothing? 🤔 Not sure if this is the proxy somehow like caching a response or if its a miniflare issue
7 Replies
James
James•16mo ago
Can you share a code snippet?
Unsmart
UnsmartOP•16mo ago
These are the server actions I have:
export async function catchPokemon(form: FormData) {
const id = form.get("id");

if (typeof id !== "string") throw new Error("Invalid ID");

const pokemon = await getPokemon(id);

await db.prepare('INSERT INTO Pokedex (id, name, abilities, types) VALUES (?, ?, ?, ?)').bind(
pokemon.id,
pokemon.name,
JSON.stringify(pokemon.abilities),
JSON.stringify(pokemon.types),
).run()
}

export async function releasePokemon(form: FormData) {
"use server";
const id = form.get("id");

if (typeof id !== "string") throw new Error("Invalid ID");
else if (Number.isNaN(Number(id))) throw new Error("Invalid ID");

await db.prepare('DELETE FROM Pokedex WHERE id = ?').bind(Number(id)).run()
}

export async function isPokemonCaught(id: string) {
const data = await db.prepare('SELECT * FROM Pokedex WHERE id = ?').bind(Number(id)).first();

console.log({ data })

return !!data
}
export async function catchPokemon(form: FormData) {
const id = form.get("id");

if (typeof id !== "string") throw new Error("Invalid ID");

const pokemon = await getPokemon(id);

await db.prepare('INSERT INTO Pokedex (id, name, abilities, types) VALUES (?, ?, ?, ?)').bind(
pokemon.id,
pokemon.name,
JSON.stringify(pokemon.abilities),
JSON.stringify(pokemon.types),
).run()
}

export async function releasePokemon(form: FormData) {
"use server";
const id = form.get("id");

if (typeof id !== "string") throw new Error("Invalid ID");
else if (Number.isNaN(Number(id))) throw new Error("Invalid ID");

await db.prepare('DELETE FROM Pokedex WHERE id = ?').bind(Number(id)).run()
}

export async function isPokemonCaught(id: string) {
const data = await db.prepare('SELECT * FROM Pokedex WHERE id = ?').bind(Number(id)).first();

console.log({ data })

return !!data
}
James
James•16mo ago
Are you are using the latest version of the proxy right?
Unsmart
UnsmartOP•16mo ago
nope its very old KEKW shoulda checked that lemme see if it works
James
James•16mo ago
Yeah because the cache option was changed to no-store in the proxy in v0.2.6
Unsmart
UnsmartOP•16mo ago
Ah yeah I had 0.2.3... new one works as expected
James
James•16mo ago
Perfect
Want results from more Discord servers?
Add your server