Cannot find name ‘request’. Did you mean ‘Request’? ts(2552)

I have the following js code:

let sig = request.headers["stripe-signature"];
try {
  let event = stripe.webhooks.constructEvent(request.rawBody, sig, endpointSecret);
} catch (err) {
  return response.status(400).end();

I need this code to be converted to typescript. Which I think would solve the error I am getting:

Cannot find name ‘request’. Did you mean ‘Request’?ts(2552)


request is a variable and it must be defined. You have copy and pasted a single piece of a tutorial, but this code snippet doesn’t work in isolation.

The tutorial uses this code inside of a function which gets the request variable from its arguments. = functions.https.onRequest((request, response) => {

  let sig = request.headers["stripe-signature"];

You can see this more clearly in their completed code.

Leave a Reply

Your email address will not be published. Required fields are marked *