Getting error in sending html file from express response

Getting error in sending html file from express response

I am trying to show local index file in response in a Node and express application ,but didn't succeeded yet.

I am trying to show local index file in response in a Node and express application ,but didn't succeeded yet.

This is what I am doing :-

router.get('/verify',function(req,res){

console.log('request recieved');
const emailtoken = req.query.id;
console.log(emailtoken);

User.updateOne( { emailResetToken: emailtoken },{ $set: { isVerified: true }},(err) =>{

if(!err){
    res.type('.html').sendFile('./index.html', {root: __dirname }); 
}
else{
    throw err;
}

}); });

For work around I have hosted my index file in AWS bucket and called which is successful .

if(!err){
        return res.redirect('https://s3.ap-south-1.amazonaws.com/xyz/index.html');
}

I want to call my file within the project rather than hosting and calling from other source. I tried few suggestions but not getting success. Am I doing any mistake ?

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

How to Use Express.js, Node.js and MongoDB.js

In this post, I will show you how to use Express.js, Node.js and MongoDB.js. We will be creating a very simple Node application, that will allow users to input data that they want to store in a MongoDB database. It will also show all items that have been entered into the database.

Secure Node.js, Express.js and PostgreSQL API using Passport.js

The comprehensive step by step tutorial on building secure Node.js, Express.js, Passport.js, and PostgreSQL Restful Web Service

Creating a RESTful Web API with Node.js and Express.js from scratch

In this article, I’ll show you step by step how to create a RESTful Web API with Node.js and Express.js by building a simple and useful Todo API. This article assumes you have basic javascript knowledge and terminal using capabilities.