Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello,
We've set up a Shopify Remix app and added a settings page that allows users to store an API token using the following Prisma model:
model ApiToken { id Int @id @default(autoincrement()) token String @unique createdAt DateTime @default(now()) updatedAt DateTime @updatedAt }
We also implemented the following server-side functions to manage the API token:
import { db } from "../db.server"; export async function getInnosendApiToken() { const token = await db.apiToken.findFirst(); if (!token) { return null; } return token; } export async function setInnosendApiToken(token: string) { await db.apiToken.upsert({ where: { id: 1 }, // Assuming you have a unique identifier for the token update: { token }, create: { token }, }); }
The issue arises when we try to access this token within the Shopify Pickup Point Options Generator extension. Importing the server function results in WASM errors, and using a fetch request inside the buildExternalApiRequest function within fetch.ts leads to type conflicts with FetchInput.
The working example below uses a hardcoded token (which is obviously not a good solution):
function buildExternalApiRequest( latitude: number, longitude: number, countryCode: CountryCode, ): HttpRequest { const url = `http://localhost:5000/v1/pickup-point?latitude=${latitude}&longitude=${longitude}&country_code=${countryCode}`; const apiToken = "FwCmZtYT_ELfWelibiLU1fmJYQz0yxKCVMX9HGvjMUSCf9UwtHqGwtU9JLjgRBvP3QhchQS3iB1vKAVl_AtxAg"; return { method: HttpRequestMethod.Get, url, headers: [ { name: "Accept", value: "application/json; charset=utf-8", }, { name: "Authorization", value: `Bearer ${apiToken}`, }, ], body: null, policy: { readTimeoutMs: 1000, }, }; }
My questions:
I appreciate any guidance or suggestions on how to solve this!
Thanks in advance!
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025