Skip to content

twilio.webhook is not a function #1123

@crizant

Description

@crizant

Hi, I'm using twilio package version 5.8.0 from npm, with TypeScript and Express.js.
When I tried to use the express middleware, I see the following in the console:

twilio.webhook({
         ^


TypeError: twilio.webhook is not a function

Here is my code, from the typing it's absolutely fine:

import { Router } from "express";
import handler from "./handler.js";
import * as twilio from "twilio";

const router = Router();

router.post(
  "/",
  twilio.webhook({
    authToken: process.env.TWILIO_AUTH_TOKEN,
  }),
  handler
);

export default router;

I got my code by referencing this page:
https://www.twilio.com/docs/usage/tutorials/how-to-secure-your-express-app-by-validating-incoming-twilio-requests
Is it outdated?

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumImportant but not urgent; Workaround availabletype: questionquestion directed at the library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions