-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed as not planned
Labels
needs reproIssue needs a reproductionIssue needs a reproduction
Description
Astro Info
Astro v4.15.1
Node v18.20.4
System Windows (x64)
Package Manager unknown
Output hybrid
Adapter none
Integrations @astrojs/tailwind
@astrojs/preact
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
Got TS2305: Module "astro:actions" has no exported member actions
when import { actions } from 'astro:actions';
full code:
my actions/index.ts
import { defineAction, ActionError } from 'astro:actions';
import { z } from "astro:content";
import {app} from '../firebase/server.ts';
import { getFirestore } from 'firebase-admin/firestore';
export const server = {
getData: defineAction({
input: z.object({
docName: z.string().min(1),
}),
handler: async (input: { docName: string }) => {
try {
const db = getFirestore(app);
const doc = await db.collection('test').doc(input.docName).get();
console.log('doc.data()', doc.data());
return doc.data();
} catch (error) {
return new ActionError({
code: 'INTERNAL_SERVER_ERROR',
message: `An error occurred while fetching data: ${error.message}`,
});
}
}
})
};
my preact component
import { actions } from 'astro:actions';
import {useEffect, useState} from "preact/hooks";
export default function TestFirebase() {
const [data, setData] = useState([]);
useEffect(() => {
const f = async () => {
const d = await actions.getData({docName: 'test'})
setData(d)
}
f()
}, [])
return (
<div>
<h1>TestFirebase</h1>
<ul>
{
data.map((d) => <li>d</li>)
}
</ul>
</div>
);
}
index.astro
import { defineAction, ActionError } from 'astro:actions';
import { z } from "astro:content";
import {app} from '../firebase/server.ts';
import { getFirestore } from 'firebase-admin/firestore';
export const server = {
getData: defineAction({
input: z.object({
docName: z.string().min(1),
}),
handler: async (input: { docName: string }) => {
try {
const db = getFirestore(app);
const doc = await db.collection('test').doc(input.docName).get();
console.log('doc.data()', doc.data());
return doc.data();
} catch (error) {
return new ActionError({
code: 'INTERNAL_SERVER_ERROR',
message: `An error occurred while fetching data: ${error.message}`,
});
}
}
})
};
What's the expected result?
it should import actions correctly
Link to Minimal Reproducible Example
Participation
- I am willing to submit a pull request for this issue.
Metadata
Metadata
Assignees
Labels
needs reproIssue needs a reproductionIssue needs a reproduction