wedmaniac
wedmaniac
DDeno
Created by wedmaniac on 11/30/2024 in #help
Parsing a fetch response resulting number turning into NaN
Maby I encounter it in the future:)
16 replies
DDeno
Created by wedmaniac on 11/30/2024 in #help
Parsing a fetch response resulting number turning into NaN
I was really baffled so I had to change direction! Now I include the data in the context!
16 replies
DDeno
Created by wedmaniac on 11/30/2024 in #help
Parsing a fetch response resulting number turning into NaN
No sir!
16 replies
DDeno
Created by wedmaniac on 11/30/2024 in #help
Parsing a fetch response resulting number turning into NaN
Hi, thx for the reply ! Yes. I have tried that!;)
16 replies
DDeno
Created by wedmaniac on 11/30/2024 in #help
Parsing a fetch response resulting number turning into NaN
It is a 8 byte int so im pretty certain its a 5:)
16 replies
DDeno
Created by wedmaniac on 11/30/2024 in #help
Parsing a fetch response resulting number turning into NaN
I feel like im going insane!
16 replies
DDeno
Created by wedmaniac on 11/30/2024 in #help
Parsing a fetch response resulting number turning into NaN
So im not crazy:P
16 replies
DDeno
Created by wedmaniac on 11/27/2024 in #help
Loop Detected in Deno Deploy
No worries! Thanks anyway:)
11 replies
DDeno
Created by wedmaniac on 11/27/2024 in #help
Loop Detected in Deno Deploy
thanks a ton, will try them both and see which one i like most then;)
11 replies
DDeno
Created by wedmaniac on 11/27/2024 in #help
Loop Detected in Deno Deploy
Thansk for responding;) So I shouldn't do a fetch call at all? Should I have a helper function of some kind to retrieve the data, or should i just put the code in the /paths/[slug].tsx?
11 replies
DDeno
Created by wedmaniac on 11/27/2024 in #help
Loop Detected in Deno Deploy
The error was the attached image. Not sure if you mean someting else:)
11 replies
DDeno
Created by wedmaniac on 11/27/2024 in #help
Loop Detected in Deno Deploy
Which I use in one of my routes: /paths/[slug].tsx
export default async function PathPage(req: Request, ctx: FreshContext<SignedInState>) {
const { session } = ctx.state;
const slug = ctx.params.slug;
let modules: Module[] = [];


try {
// Run both fetch requests in parallel
const [modulesResp, pathResp] = await Promise.all([
fetch(`https://economics.gg/api/get/modules?pathId=${slug}`, { redirect: "manual" }),
.....,
]);

// Handle modules response
if (modulesResp.ok) {
const data = await modulesResp.json();
modules = data.modules || []; // Set modules from response or empty array
} else {
console.error("Failed to fetch modules:", modulesResp.statusText);
}
} catch (error) {
console.error("Error fetching data:", error);
}
export default async function PathPage(req: Request, ctx: FreshContext<SignedInState>) {
const { session } = ctx.state;
const slug = ctx.params.slug;
let modules: Module[] = [];


try {
// Run both fetch requests in parallel
const [modulesResp, pathResp] = await Promise.all([
fetch(`https://economics.gg/api/get/modules?pathId=${slug}`, { redirect: "manual" }),
.....,
]);

// Handle modules response
if (modulesResp.ok) {
const data = await modulesResp.json();
modules = data.modules || []; // Set modules from response or empty array
} else {
console.error("Failed to fetch modules:", modulesResp.statusText);
}
} catch (error) {
console.error("Error fetching data:", error);
}
11 replies
DDeno
Created by wedmaniac on 11/27/2024 in #help
Loop Detected in Deno Deploy
below is my /api/get/modules/
import { Handlers } from "$fresh/server.ts";
import { createSupabaseClient } from "../../../plugins/auth.ts";
export const handler: Handlers = {
async GET(req, _ctx) {
const headers = new Headers();
const resp = new Response();
try {
const url = new URL(req.url); // Parse the URL

const pathId = url.searchParams.get("pathId");
console.log(pathId);

// Validate the header
if (!pathId) {
return new Response(
JSON.stringify({ success: false, message: "Path id header missing." }),
{ status: 400, headers }

);
}
const supabaseClient = createSupabaseClient(req, resp);

// Fetch modules for the given path slug
const { data: path, error: pathError } = await supabaseClient
.from("paths")
.select("id")
.eq("id", pathId)
.single();

if (pathError || !path) {
return new Response(
JSON.stringify({ success: false, message: "Path not found." }),
{ status: 404, headers }
);
}

const { data: modules, error: modulesError } = await supabaseClient
.from("modules")
.select("*")
.eq("path_id", path.id);

if (modulesError) {
console.error("Error fetching modules:", modulesError.message);
return new Response(
JSON.stringify({ success: false, message: "Failed to fetch modules." }),
{ status: 500, headers }
);
}

return new Response(
JSON.stringify({ success: true, modules }),
{ status: 200, headers }
);
}
.....
}
}
import { Handlers } from "$fresh/server.ts";
import { createSupabaseClient } from "../../../plugins/auth.ts";
export const handler: Handlers = {
async GET(req, _ctx) {
const headers = new Headers();
const resp = new Response();
try {
const url = new URL(req.url); // Parse the URL

const pathId = url.searchParams.get("pathId");
console.log(pathId);

// Validate the header
if (!pathId) {
return new Response(
JSON.stringify({ success: false, message: "Path id header missing." }),
{ status: 400, headers }

);
}
const supabaseClient = createSupabaseClient(req, resp);

// Fetch modules for the given path slug
const { data: path, error: pathError } = await supabaseClient
.from("paths")
.select("id")
.eq("id", pathId)
.single();

if (pathError || !path) {
return new Response(
JSON.stringify({ success: false, message: "Path not found." }),
{ status: 404, headers }
);
}

const { data: modules, error: modulesError } = await supabaseClient
.from("modules")
.select("*")
.eq("path_id", path.id);

if (modulesError) {
console.error("Error fetching modules:", modulesError.message);
return new Response(
JSON.stringify({ success: false, message: "Failed to fetch modules." }),
{ status: 500, headers }
);
}

return new Response(
JSON.stringify({ success: true, modules }),
{ status: 200, headers }
);
}
.....
}
}
11 replies
DDeno
Created by wedmaniac on 5/28/2024 in #help
Is it possible to change a fresh.js project to build ahead-of-time
It all seems to work! Thanks again @marvinh.!
4 replies
DDeno
Created by wedmaniac on 5/28/2024 in #help
A Question about Tailwind plugins in Fresh
Thanks for the clarification!:P
13 replies
DDeno
Created by wedmaniac on 5/28/2024 in #help
A Question about Tailwind plugins in Fresh
Haha, ohhh my! Im dufos!:P
13 replies
DDeno
Created by wedmaniac on 5/28/2024 in #help
A Question about Tailwind plugins in Fresh
@marvinh. Im actually not sure that it works as intended. There is no errors in the console but i don't think the plugin works. You said that I need to match the versions, am I using tailwind 0.16.19? Do you think i need to upgrade it in order to use the plugin? Bellow is my imports:
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.5.2/",
"preact": "https://esm.sh/preact@10.18.1",
"preact/": "https://esm.sh/preact@10.18.1/",
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.2.2",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.1",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.0",
"twind": "https://esm.sh/twind@0.16.19",
"twind/": "https://esm.sh/twind@0.16.19/",
"tailwindcss/plugin": "npm:/tailwindcss@3.4.3/plugin.js",
"$std/": "https://deno.land/std@0.193.0/",
"@supabase/supabase-js": "https://esm.sh/@supabase/supabase-js@2.21.0",
"@supabase/gotrue-js":"https://esm.sh/@supabase/gotrue-js",
"@/": "./",
"./": "./",
"$gfm": "https://deno.land/x/gfm@0.1.26/mod.ts",
"feed": "https://esm.sh/feed@4.2.2"
},
"imports": {
"$fresh/": "https://deno.land/x/fresh@1.5.2/",
"preact": "https://esm.sh/preact@10.18.1",
"preact/": "https://esm.sh/preact@10.18.1/",
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.2.2",
"@preact/signals": "https://esm.sh/*@preact/signals@1.2.1",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.0",
"twind": "https://esm.sh/twind@0.16.19",
"twind/": "https://esm.sh/twind@0.16.19/",
"tailwindcss/plugin": "npm:/tailwindcss@3.4.3/plugin.js",
"$std/": "https://deno.land/std@0.193.0/",
"@supabase/supabase-js": "https://esm.sh/@supabase/supabase-js@2.21.0",
"@supabase/gotrue-js":"https://esm.sh/@supabase/gotrue-js",
"@/": "./",
"./": "./",
"$gfm": "https://deno.land/x/gfm@0.1.26/mod.ts",
"feed": "https://esm.sh/feed@4.2.2"
},
13 replies
DDeno
Created by wedmaniac on 5/28/2024 in #help
A Question about Tailwind plugins in Fresh
I think it all works now, thanks a ton!:P
13 replies
DDeno
Created by wedmaniac on 5/28/2024 in #help
A Question about Tailwind plugins in Fresh
D:\Indie Array\indiearray.com>deno task start
Task start deno run -A --watch=static/,routes/ dev.ts
Watcher Process started.
error: Relative import path "tailwindcss/plugin" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v135/tailwindcss-animate@1.0.7/X-ZS90YWlsd2luZGNzcw/denonext/tailwindcss-animate.mjs"
at https://esm.sh/v135/tailwindcss-animate@1.0.7/X-ZS90YWlsd2luZGNzcw/denonext/tailwindcss-animate.mjs:2:23
Watcher Process failed. Restarting on file change...
D:\Indie Array\indiearray.com>deno task start
Task start deno run -A --watch=static/,routes/ dev.ts
Watcher Process started.
error: Relative import path "tailwindcss/plugin" not prefixed with / or ./ or ../ and not in import map from "https://esm.sh/v135/tailwindcss-animate@1.0.7/X-ZS90YWlsd2luZGNzcw/denonext/tailwindcss-animate.mjs"
at https://esm.sh/v135/tailwindcss-animate@1.0.7/X-ZS90YWlsd2luZGNzcw/denonext/tailwindcss-animate.mjs:2:23
Watcher Process failed. Restarting on file change...
13 replies
DDeno
Created by wedmaniac on 5/28/2024 in #help
A Question about Tailwind plugins in Fresh
Thanks for the quick respond. My config file looks like this:
import { Options } from "$fresh/plugins/twind.ts";
import animate from "https://esm.sh/tailwindcss-animate@1.0.7";

export default {
selfURL: import.meta.url,
plugins: [
animate,
],
theme: {
extend: {
animation: {
"bounce-delayed": "bounce 1s linear infinite 1s"
}
}
}
} as Options;
import { Options } from "$fresh/plugins/twind.ts";
import animate from "https://esm.sh/tailwindcss-animate@1.0.7";

export default {
selfURL: import.meta.url,
plugins: [
animate,
],
theme: {
extend: {
animation: {
"bounce-delayed": "bounce 1s linear infinite 1s"
}
}
}
} as Options;
I haven't installed it through npm.
13 replies