Serialization of a User Object 5

Tell us what’s happening:
Describe your issue in detail here.
ReferenceError: TextEncoder is not defined

12:27 PM

Your code so far

'use strict';

require('dotenv').config();

const express = require('express');

const myDB = require('./connection');

const fccTesting = require('./freeCodeCamp/fcctesting.js');

const pug = require('pug');

const session = require('express-session');

const passport = require('passport');

const ObjectID = require('mongodb').ObjectID;

const utf8 = require('utf8');

​

const app = express();

app.set('view engine','pug');

​

​

​

fccTesting(app); //For FCC testing purposes

app.use('/public', express.static(process.cwd() + '/public'));

app.use(express.json());

app.use(express.urlencoded({ extended: true }));

​

app.use(session({

secret: process.env.SESSION_SECRET,

resave: true,

saveUninitailized: true,

cookie: {secure: false}

}));

app.use(passport.initialize());

app.use(passport.session());

​

app.route('/').get((req, res) => {

res.render(process.cwd() + '/views/pug',{title: "Hello",

message: "Please login"});

});

​

passport.serializeUser((user, done) => {

done(null, user._id);

});

passport.deserializeUser((id, done) => {

// myDB.findOne({ _id: new ObjectID(id) }, (err, doc) => {

done(null, null);

//});

});

​

const PORT = process.env.PORT || 3000;

app.listen(PORT, () => {

console.log('Listening on port ' + PORT);

});

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 10; LM-K300) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Mobile Safari/537.36

Challenge: Serialization of a User Object

Link to the challenge:

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

My first instinct would be to find where in your code TextEncoder is being referenced. Of course it isn’t, here. Could it be in another file? Do you have a link to an online IDE or a repo?

If that isn’t the case, then presumably it is in one of the libraries you are referencing, either because they have a bug or you are using it incorrectly. If you know it is not being used in your code directly, then I would google that error and maybe check the issues for those libraries.

Thanks I figured that issue out but now I cant connect to mongodb im using glitch does it have a bug or something I wanted to try to use mongoose but the lesson does not require it

Sorry, I don’t have specific information on that combination.

I would do some google searches and look at the Glitch documentation and their support forum. This is roughly what a professional dev does when they run into a problem like this.

Ok thanks I will see if I can figure it out

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.