We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ive took every step that you did but yet im getting this error and i just cant find where is the problem?
const mongoose = require('mongoose'); const { Schema } = mongoose;
const UserSchema = new Schema({ googleId: String, credits: { type: Number, default: 0} });
mongoose.model('users', UserSchema);
//Route code const keys = require('../config/keys'); const stripe = require('stripe')(keys.stripeSecretKey); const User = require('../models/User');
module.exports = app => { app.post('/api/stripe', async (req, res) => { const charge = await stripe.charges.create({ amount: 500, currency: 'usd', description: '$5 for 5 credits', source: req.body.id }); req.user.credits += 5; const user = await req.user.save();
res.send(user);
}); };
//Index file const express = require('express'); const mongoose = require('mongoose'); const keys = require('./config/keys'); const bodyParser = require('body-parser'); const passport = require('passport'); require('./models/User'); require('./services/passport');
mongoose.connect(keys.mongoURI); const app = express();
app.use(bodyParser.json()); app.use(cookieSession({ maxAge: 30 * 24 * 8 * 8 * 1000, keys: [keys.cookieKey] })); app.use(passport.initialize()); app.use(passport.session());
require('./routes/authRoutes')(app); require('./routes/billingRoutes')(app);
const PORT = process.env.PORT || 5000; app.listen(PORT); console.log('The server is running!');
The text was updated successfully, but these errors were encountered:
you solved this error ?? if solved then please tell me i also face same error
Sorry, something went wrong.
No branches or pull requests
Ive took every step that you did but yet im getting this error and i just cant find where is the problem?
const mongoose = require('mongoose');
const { Schema } = mongoose;
const UserSchema = new Schema({
googleId: String,
credits: { type: Number, default: 0}
});
mongoose.model('users', UserSchema);
//Route code
const keys = require('../config/keys');
const stripe = require('stripe')(keys.stripeSecretKey);
const User = require('../models/User');
module.exports = app => {
app.post('/api/stripe', async (req, res) => {
const charge = await stripe.charges.create({
amount: 500,
currency: 'usd',
description: '$5 for 5 credits',
source: req.body.id
});
req.user.credits += 5;
const user = await req.user.save();
});
};
//Index file
const express = require('express');
const mongoose = require('mongoose');
const keys = require('./config/keys');
const bodyParser = require('body-parser');
const passport = require('passport');
require('./models/User');
require('./services/passport');
mongoose.connect(keys.mongoURI);
const app = express();
app.use(bodyParser.json());
app.use(cookieSession({
maxAge: 30 * 24 * 8 * 8 * 1000,
keys: [keys.cookieKey]
}));
app.use(passport.initialize());
app.use(passport.session());
require('./routes/authRoutes')(app);
require('./routes/billingRoutes')(app);
const PORT = process.env.PORT || 5000;
app.listen(PORT);
console.log('The server is running!');
The text was updated successfully, but these errors were encountered: