JWT Token Not Being Created When Signing Up

I am trying to have a register form create a JWT token when the user submits but I get the error

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

because I send 2 responses in my sign up.

exports.signup = async (req, res, next)=> {
    const {email} = req.body;
    const userExist = await User.findOne({email});

    if (userExist) {
        return next(new ErrorResponse(`Email already exists`, 404))

    try {
        const user = await User.create(req.body);

            success: true,

        //this is the second request but how do I combine it with the code up top to be one request?
        generateToken(user, 200, res);

    } catch (error) {
//my generate token method
const generateToken = async (user, statusCode, res) => {
    const token = await user.jwtGenerateToken();
    var hour = 3600000;
    const options = {
        httpOnly: true,
        expires: new Date(Date.now() + hour)
    .cookie('token', token, options)
    .json({success: true, token})