Failed to load function code

Getting : Failed to load function code Unexpected token 'A', "An error o"... is not valid JSON
No description
2 Replies
silentworks
silentworks5w ago
Try in a different browser as I just tested mine here and it's working.
-N I N J A-
-N I N J A-OP4w ago
No, It works for simple functions but for functions that have google purchase verification/billing it fails If function is like:
import { google } from "npm:googleapis";
import "jsr:@supabase/functions-js/edge-runtime.d.ts"
import { createClient } from "https://esm.sh/@supabase/supabase-js@2";

const supabase = createClient(Deno.env.get("SUPABASE_URL"), Deno.env.get("SUPABASE_SERVICE_ROLE_KEY"));

const packageName = "com.xyz";

Deno.serve(async () => {
try {
const { data: subscriptions, error } = await supabase
.from("subscriptions")
.select("id, user_id, purchase_token, product_id");

if (error) throw error;

const serviceAccount = JSON.parse(Deno.env.get("GOOGLE_SERVICE_ACCOUNT_JSON"));

const auth = new google.auth.GoogleAuth({
credentials: serviceAccount,
scopes: ["https://www.googleapis.com/auth/androidpublisher"],
});

const authClient = await auth.getClient();
const androidpublisher = google.androidpublisher({
version: "v3",
auth: authClient,
});

const now = Date.now();
....
});
import { google } from "npm:googleapis";
import "jsr:@supabase/functions-js/edge-runtime.d.ts"
import { createClient } from "https://esm.sh/@supabase/supabase-js@2";

const supabase = createClient(Deno.env.get("SUPABASE_URL"), Deno.env.get("SUPABASE_SERVICE_ROLE_KEY"));

const packageName = "com.xyz";

Deno.serve(async () => {
try {
const { data: subscriptions, error } = await supabase
.from("subscriptions")
.select("id, user_id, purchase_token, product_id");

if (error) throw error;

const serviceAccount = JSON.parse(Deno.env.get("GOOGLE_SERVICE_ACCOUNT_JSON"));

const auth = new google.auth.GoogleAuth({
credentials: serviceAccount,
scopes: ["https://www.googleapis.com/auth/androidpublisher"],
});

const authClient = await auth.getClient();
const androidpublisher = google.androidpublisher({
version: "v3",
auth: authClient,
});

const now = Date.now();
....
});
It fails to load function.

Did you find this page helpful?