该应用程序由 Next.js 运行。我有一个 useQueries 钩子:const userQueries = useQueries({ queries: user.contacts.map((contactId: string) => ({ queryKey: ['contact', conta...
该应用程序由 Next.js 运行。
我有一个 useQueries 钩子:
const userQueries = useQueries({
queries: user.contacts.map((contactId: string) => ({
queryKey: ['contact', contactId],
queryFn: () => getUserById(contactId),
}))
});
api.ts 文件中的函数“getUserById”:
export async function getUserById(userId: string) {
const supabase = createClient();
let {data} = await supabase
.from('users')
.select()
.eq('id', userId);
return data && data[0]
}
我发现当我以这种方式加载数据时,它会按顺序加载而不是并行加载。
我尝试将 api 函数设为非异步,以便每个请求不会等待前一个请求,但 Next.js 禁止在没有“async”前缀的情况下执行服务器操作。有办法解决这个问题吗?
我有一个 Nextjs 应用程序,它同时使用 React-Email、Resend 和 Firebase Cloud Functions。目录结构如下所示:每当在 & 中创建文档时,我都想向用户发送电子邮件...
我有一个 Nextjs 应用,它同时使用了 React-Email、Resend 和 Firebase Cloud Functions。目录结构如下所示:
我希望每当在 \'emailVerification\' 集合中创建文档时向用户发送一封电子邮件,以下是云函数的样子:
import * as logger from "firebase-functions/logger";
import {onDocumentCreated} from "firebase-functions/v2/firestore";
import { Resend } from 'resend'
import EmailVerificationTemplate from '../../react-email/emails/EmailVerification'
import { render } from '@react-email/components';
const resend = new Resend(RESEND_API_KEY);
export const sendEmailVerification = onDocumentCreated("/emailVerifications/{id}", async (event) => {
// Grab the current value of what was written to Firestore.
const data = event?.data?.data();
// Access the parameter `{documentId}` with `event.params`
logger.log("Requesting email verification for uid", event.params.id, data);
const emailHtml = render(EmailVerificationTemplate({
validationCode: data?.code.toString()
}));
await resend.emails.send({
from: '[email protected]',
to: data?.email,
subject: 'Your Halbert Verification Code',
html: emailHtml
});
});
但是,当我尝试使用以下方法部署此功能时出现此错误:firebase deploy --only functions:
我该如何解决这些错误?