$app/server
import { function getRequestEvent(): RequestEvent<Partial<Record<string, string>>, string | null>Returns the current RequestEvent. Can be used inside server hooks, server load functions, actions, and endpoints (and functions called by them).
In environments without AsyncLocalStorage, this must be called synchronously (i.e. not after an await).
getRequestEvent, function read(asset: string): ResponseRead the contents of an imported asset from the filesystem
read } from '$app/server';getRequestEvent
自 2.20.0 起可用
返回当前 RequestEvent。可在服务器钩子、服务器 load 函数、操作和端点(以及由它们调用的函数)中使用。
在无AsyncLocalStorage的环境下,必须同步调用(即不在await之后)。
function getRequestEvent(): RequestEvent<
Partial<Record<string, string>>,
string | null
>;读取
自 2.4.0 版本起可用
读取导入资产的文件系统内容
import { function read(asset: string): ResponseRead the contents of an imported asset from the filesystem
read } from '$app/server';
import const somefile: stringsomefile from './somefile.txt';
const const asset: Responseasset = function read(asset: string): ResponseRead the contents of an imported asset from the filesystem
read(const somefile: stringsomefile);
const const text: stringtext = await const asset: Responseasset.Body.text(): Promise<string>text();function read(asset: string): Response;Edit this page on GitHub llms.txt
previous next