login.js file: const form = document.getElementById('loginForm'); form.addEventListener('submit',async(e)=>{ e.preventDefault(); return await fetch(`localhost:8000/route`, { method: "get", headers: { " ...
Hey there! I'm currently facing a challenge where I need to import a function from one JavaScript file to another. Both files are on the client side in Node.js, so I can't use the require method. If I try to use the import statement, I would need ...
My current setup involves a NodeJS application with an Express backend and EJS for the frontend. The code snippet below shows an example route: router.get("/:name&:term", function(req, res) { Course.find({ courseName: req.params.name, courseTerm: req.p ...
I'm new to node and express and I'm facing a problem. I want to load a custom script.js from the public folder, but it's not loading. There are no errors in the console or anything in the network tab. When I try to access the URL localhost:3 ...
Dealing with the issue Hello everyone. I've been struggling for the past 30 minutes trying to figure out the rendering method problem I'm facing. Whenever I try to post data through a form from Page A and then render that data on Page B, I keep encounteri ...
When using express.js + ejs, I encounter two scenarios: 1. <a href="<%= prevDisabledClass ? '' : ?page=<%=+page - 1%>%>">prev</a> Unfortunately, this code throws an error: Could not find matching close tag for "<%=". ...
I am looking to convert the camp name to use hyphens instead of spaces, all in lowercase letters. Specifically, I want to replace spaces with hyphens. My approach: app.get('/:campname/edit', adminController.getUpdateCampaign); exports.getUpda ...
I'm delving into the world of EJS, Node, and Express (completely new to all three). Below you'll find my ejs file, app.js file, and directory structure. Could someone please guide me on properly setting things up? Appreciate your help in advance. ejs file ...
Is it possible to utilize express4 with underscore.js, specifically for printing the variable "name" in index.ejs? Are there any alternative methods within underscore.js that work well with node.js and Express4 capabilities? Note: underscore.js and Expre ...
Currently in the process of developing a project which involves a web server app built with nodejs + express and some client views that are rendered using ejs. In the main app.js file, the following code is present: const express = require('express'); co ...
I need some guidance on how to incorporate a ternary operator inside include ejs tags. My setup involves using node with expressjs and ejs for the js files. <% if (post) { %> <%- include('partials/metas', { pageTitle: post[ ...
I'm currently developing a simple API using Mongoose, Express, and Node.js. However, I've encountered an issue when trying to click on the "Read More" link, which utilizes Express routing parameters. Whenever I do so, I receive an error message stating "Er ...
After passing a JSON string to my EJS page, I noticed that it displays the string with inverted commas. To resolve this issue, I am looking for a way to eliminate the inverted comma's and convert the string to UPPERCASE. Does anyone know how to achiev ...
Image 1: Configuring express.static for the public folder Image 2: Adding href="/app.css" in post.ejs file Image 3: Final result While experimenting with using /app.css and app.css in the post.ejs file, I noticed that the outcome was consistent with th ...
I am currently utilizing the combination of Node.js, Express.js, and Ejs. Challenge In my particular scenario, I have 3 distinct layers: 1) clients-side.js ((node.js) 2) server.js (node.js) 3) front-end.ejs (ejs) Upon successful form submission, an e ...
Currently, I am utilizing ejs templates in combination with node.js and express 3.x. Is there a way to display the data object that is passed into the view? Can it be achieved similar to this example in index.ejs: <%= dump(session) %> ...
Hi there, I have a question regarding my implementation efforts with Node, express, mongoose, and ejs template. I've spent over four hours trying to make it work but so far no luck. My specific query is how to call a model in order to fetch all the data i ...
As a newcomer to Node.js, I am currently working on displaying all the images of a logged-in user from my database onto my EJS file. I have written the necessary code, but I am facing an issue with properly displaying all the images. I have attempted to us ...
I'm facing an issue where my layout.ejs file is not loading the style.css file. I've been searching endlessly for a solution, trying various fixes and meticulously checking for typos. Despite the correct path shown in the network tab when inspect ...
When using Express, I have encountered an issue with passing a variable to an EJS file called "index.ejs". res.render("index",{passedUser:req.user.alias}) Although I am able to successfully print it using <%=passedUser%> in the EJS file, I require ...
app.get("/articles", function(req, res){ Article.find({}, function(err, articles){ if(err){ console.log("an error occurred!!!"); }else{ res.render("homepage", `{articles: articles}`); } }); I created this c ...
I have been trying to incorporate a basic Ember application into the view of my node application. I have verified that Ember is properly set up and my sockets are functioning correctly. However, I am encountering an issue where the data is not being displa ...
const adminsSchema = new mongoose.Schema({ username: String, password: String, }); const secretKey = "CrackThis1"; adminsSchema.plugin(encrypt, { secret: secretKey, encryptedFields: ["password"] }); const AdminUser = ne ...
As someone new to web development, I'm experimenting with Node.js, Express, and EJS to create a weather application that displays the temperature based on a zipcode. So far, retrieving and showing the temperature has been successful. However, I want t ...
Currently, I am iterating over a JSON object and displaying the data in the View. Each object includes a button that I have created. However, when I attempt to perform an action upon clicking any of these buttons, only the first button seems to work. Below ...
I have a unique combination of HTML and CSS code that creates an impressive login form: <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>Prepare to be amazed...</title> <l ...
Is there a way to set a global variable in EJS that can show/hide specific elements across all views without the need to redefine it each time? I am using node.js/express/ejs for my project stack and would like to know the best approach to achieve this. B ...
I am currently working on a project to develop a basic webpage that requires the user to input a specific time and then click on submit. Once submitted, I want the relevant data linked to that input to be displayed on the webpage. Upon clicking the submit ...
Currently, I am in the process of learning Node.js and have successfully created a server using express documentation in the past. However, for a new project, I decided to incorporate some npm packages such as dotenv, http-errors, ejs, and more. I establis ...
Recently, I've been encountering problems with my CSP header in Helmet. No matter what changes I make, the links always seem to be broken or return an error. How can I go about fixing this issue? Below is my current code: app.use( helmet.conte ...
Encountering a reference error while trying to access the formula one API at this link. The specific error pertains to the inability to access MRData. Despite using JSON Editor and confirming the correct pathway, I am still facing this issue. Please find ...
After a user logs in, I would like to store their details in the session and be able to access them in ejs templates. How can this be accomplished? app.post('/registration', function(req, res) { var name = req.session.user_name = req.body.user_name; ...
Currently, I am working on a project using node.js with express framework and mysql with sequelize ORM. In this method, an API is utilized to retrieve a large amount of data which is then stored in a database table. The data is in CSV format and I am util ...
I am currently trying to implement the functionality found at this link: Below is an excerpt of my code: <html> <head> <script src="http://trentrichardson.com/examples/timepicker/js/jquery-1.7.1.min.js"> </script> < ...
Hey there, just starting out and looking to showcase my SQL query results in my EJS file. Struggling a bit with this. I'd really appreciate any guidance or assistance on this. Thanks! ...
My current project structure can be seen here: https://i.stack.imgur.com/TdqoN.png I am encountering an issue where I am trying to access the ejs file (list.ejs) located within the "views" folder from my angular routing file (main.js) in the "public" fold ...
I am currently developing a CRUD application in Nodejs/Expressjs using EJS as the templating engine. Within my "views" folder, I have created a subfolder named "login" which contains several .ejs files. All of my .ejs files are located within the views fo ...
Understanding the combination of EJS with AJAX has been a challenge for me. Most tutorials on AJAX involve using an API that responds with JSON objects. Below is an example of code: router.js router.get('/jobs', function(req, res) { Job.fi ...
Whenever I attempt to use a Foreach loop statement in my ejs code, I encounter an error message indicating that "songs.foreach is not a function" <% songs.foreach(function(song){ %> <li><%= song.name %> - <%= song.year %></ ...
I am trying to figure out how to iterate through objects in Express.js. I can retrieve information from the JSON file, but when I attempt to loop through it, I keep getting an error saying that it's not defined. What could I be missing here? My goal is to ...
Looking to fetch data from an endpoint for a header.ejs file that will be displayed on all routed files ("/", "/news" "/dogs"). Below is my app.js code: // GET API REQUEST var url = 'https://url.tld/api/'; request(url, function (error, response, body) { ...
I'm experiencing a strange issue where I have successfully used the res.render function multiple times in the past, but now I am receiving an error with the same code. The HTML file is definitely located in the views folder, so I'm not sure what could be ...
I have incorporated EJS, Express/NodeJs, and MongoDB into the project, along with ReactJs as an addition. My next step is to introduce Webpack for bundling both EJS and ReactJs files together. Although the end goal is to transition the p ...
My goal is to develop a trivia game with interactive features. I aim to enable users to click on an answer, which will trigger a border effect and increase the points variable. Below is the layout of the entire page: <% include ../partials/boilerp ...
Despite my best efforts, I keep encountering the same error repeatedly: ReferenceError: D:\Secrets - Starting Code\views\submit.ejs:8 6| <h1 class="display-3">Secrets</h1> 7| >> 8| <%usersWith ...
(Working with MEAN Stack and UI Router) In the code snippet below, a json response is sent for the specified route. While this setup functions properly when the template is rendered using UI Router, an issue arises upon page reload. Due to the response co ...
Hey there, I'm a beginner when it comes to MongoDB. Currently, I am working on a website where I want to retrieve data from a MongoDB collection based on a {Name: String} field within that Collection and showcase it in an HTML Table. Here's what I have s ...
Encountering a type error with Express Router middleware. See below for the code snippets and error details. Any assistance is appreciated? The application is functioning properly, but when attempting to access the URL in the browser, the following error ...
I am currently working on developing a dashboard for my Node.js project. The aim is to calculate the sum of certain values for an overview. While the SELECT statement works fine in my MySQL database, when I incorporate it into my Node project, I do not rec ...
Looking to implement functionality where each list item can be removed from a Node.js array by clicking on an HTML button using EJS and Express: I am considering placing an HTML button next to each list element so that the selected element can be removed ...
Beginner embarking on my inaugural project here. I have developed 2 Mongoose schematics and models for managing categories and products. The products are nested within the corresponding categories model. Using Node and Express, I successfully sent all ca ...
I've been contemplating how to add multi-language support to my personal website, which I developed using ExpressJS and NodeJS with EJS as the template engine. Currently, the website is only available in English, but I want to add a German version as ...
I am currently learning node.js and still relatively new to it. Please excuse me if my first question is inefficient or poorly formatted. I am trying to upload a one-page test to explore A2's node.js service. Following tutorials from A2 on creating a ...
Currently, I am integrating discord.js with express and facing a challenge. I want my webpage to automatically update whenever the client.on("message") event is triggered. According to my knowledge and research, it seems that rendering an ejs template is o ...
My Node.js app works perfectly fine locally, but once deployed on Heroku, it fails to run. I have already deployed it from my Github repository. If anyone could try deploying the app from my repo and identify the cause of the issue, that would be greatly ...
From what I understand, there is no .toObect() function in JavaScript, but it is used in mongoose to convert mongoose documents into objects so that JavaScript built-in functions can be used. I sometimes struggle with when to use it. There are instances w ...
Looking to enhance user experience on my form where users can select inputs. Specifically, I want to implement a feature where as the user starts typing in a text input field with data from a MYSQL database, suggestions will be displayed. The form is locat ...
I'm developing a website with Node JS and I want to implement a feature where if the user attempts to navigate to a non-existent page, they are redirected to a "Page Not Found" message before being automatically taken back to the home page after a few ...
Apologies if I'm not explaining this well in advance. I am looking to create a dynamic webpage using JavaScript that automatically updates every 10 seconds. Does anyone have an example code snippet for this? **Specifically, allow ...
I'm currently working on a project to create a dynamic website where users can update text fields directly from the site. However, I've encountered an issue on the 'admin' page where nothing happens when the button is pressed to set the field using an AJAX ...
I'm currently working on an Express GET function where I am sending data to an EJS file using the res.render() function. My question is, how can I access this data in plain JavaScript within the same EJS file? Here is my GET Function: router.get(&a ...
Hey guys, I'm having an issue with rendering a MongoDB record in my .ejs file. Strangely, when I console.log the variable before the end of my route, I get the expected value. However, it becomes undefined in the .ejs file. Here is the code snippet: rout ...
My routes are configured as follows: router.get('/', function(req, res) { res.render('index', {}); }); router.post('/application', function(req, res) { res.render('application', {twitchLink : req.query.twitch ...
I am looking to incorporate a color into my .ejs file. Here is the code snippet I am working with: <% resultList.forEach(function(item, index){ %> <tr> <td><%= item.function %></td> <td><%= item.value %>< ...
I'm working on a Todo List project using nodeJs, and I'm struggling to connect the CSS file. I've added the CSS file in header.ejs and included it in list.ejs file, but for some reason, the CSS file is still not being linked properly. ...
If item.description is not defined or empty, how can I default to 'No description'? Here are the options I've experimented with: <%-: (item.description | markdown) || '<p>No description</p>' %> <%-: (item.des ...
Is there a way to display multiple .ejs files in a nested structure? Consider the code snippet below: var mysql = require('mysql'); var ejs = require('ejs'); exports.index = function(req, res){ if (req.method=='POST'){ ...
I am having difficulty extracting data from a mongodb using a specific route. My objective is to retrieve the title fields from each object. Below is the schema: var mongoose = require('mongoose'); var Schema = mongoose.Schema; var GiveSchema = ne ...
I'm currently developing a simple calendar application using Node.js and ejs. I am working on passing an array of months through express to my ejs file, with the goal of being able to cycle through each month by clicking the next button. How can I implemen ...
Currently, I store data in mongo for a multiple-choice question and indicate the correct answers. In mongo, I save them like this: question.options.option1.check = "on" for the correct answers. When I navigate to the "edit" page, I retrieve the specific ...
var list = [ { title : '', author : '', content : '', } ] router.get('/japan',function(req,res){ var sql = 'select * from japan'; conn.query(sql,function(err,rows,fields){ for(var i = 0 ; ...
After dedicating an hour to watching instructional YouTube videos on Vue.js, I am still struggling to grasp the language! In the past, I have worked with Node.js, Jquery, and Mongodb to develop websites... I believe that web applications require multiple ...
Encountering a problem locating the include file "partials/navbar.ejs" in my node.js application Troubleshooting issue: Node.js - EJS - incorporating a partial Error message indicating difficulty finding the include file "partials/navbar.ejs" within my n ...
When using email-template-v2 in nodejs to send dynamic data to a template, only the variable is displayed instead of the dynamic content. Here is the code snippet: var template = new EmailTemplate(templateDir) var nodemailer = require('nodemailer&ap ...
I've been diving into a YouTube tutorial on building a blog with node, MongoDB, and express. There are certain concepts that I'm finding tricky to grasp. <!--Creating the Article Cards--> <% article.forEach(article =>{ %& ...