awake-maroonA
Apify & Crawlee3y ago
7 replies
awake-maroon

how can I mount the `createPlaywrightRouter()` properly?

I don't understand why crawlee is throwing an error about adding a router for the label undefined.

here's my code:
// routes.ts
export const createRouter = (args: { input: z.infer<typeof InputSchema> }) => {
    const router = createPlaywrightRouter();

    // ----- CHECK SESSION -----
    router.addDefaultHandler(async ({ session, page }) => {
    // ...
    });
    return router;
};


Which I'm importing into the main.ts file:
import { createRouter } from "./routes";

const requestHandler = createRouter({ input: inputValidation.data });
const crawler = new PlaywrightCrawler({
    requestHandler,
    },
});


TypeScript is happy with it, so I'm not sure why I get this error:
Was this page helpful?