0
votes

I have created a cloud function with the following: I'm trying to make an app/platform where a user can sign up for an account using Stripe Connect. I have a database with Firestore and the backend is using firebase cloud functions and nodejs.

const functions = require('firebase-functions');
const express = require('express');
const stripe = require('stripe')('sk_test_51XXX');
const admin = require('firebase-admin');
admin.initializeApp();


exports.createStripeUser = functions.https.onRequest((req, res) => {

    var auth_code = stripe.oauth.token({
        grant_type: 'authorization_code',
        code: req.query.code,
});return res.send("Please close this page")

}
)

My problem is that I have an error where the req, res is. I don't know why there is an error, is the request wrong? What can I do so that I get no error and fix the problem? enter image description here

If I hover on req, I get this message

(parameter) req: any
Parameter 'req' implicitly has an 'any' type.ts(7006)

I am using typescript

1
What is the error ? - Dharmaraj
@Dharmaraj Hi, I just uploaded a picture of what it looks like on my console, the error is the req, res. I don't know why there is an error. - Dijon
Can you hover on req and take a screenshot of the error? Are you using TS or (ESLint) by chance ? - Dharmaraj
@Dharmaraj Hello there, I have just edited it. I don't know how to take a screenshot while hovering but I copied the message of the error I got. - Dijon

1 Answers

0
votes

It seems you are using Typescript and req, res are implicitly of type any. You can import Request and Response from Express as shown below:

import { Request, Response } from "express"

export const createStripeUser = functions.https.onRequest((req: Request, res: Response) => {
 // ...
})

And yes, explicitly adding any like (req: any, res: any) will remove that error too but that isn't the best thing to do.