Category : javascript

I have a txt file with many lines of input, and a code that reads the file line by line that works perfectly. Now I would like to improve the code by adding a button that would jump to a specific sentence in the text, but I’m having a lot of trouble with it. my ..

Read more

I have a pretty simple form. I want to show the message "Please say something! I want to hear from you!" on my website when people leave the fields empty. How to go about it ? <form action="/action_page.php"> <label for="name">Name</label> <input type="text" id="name" name="name"><br><br> <label for="email">Email</label> <input type="text" id="email" name="email"><br><br> <label for="comment">Comment</label> <input type="text" id="comment" ..

Read more

When I type in the /posts/whatever at the end of the root URL it does not add what comes after the /posts to the console.log app.get("/posts/:userId", function(req, res) { console.log(req.params.userId); }); Edit: Heres the full code: //jshint esversion:6 const express = require("express"); const bodyParser = require("body-parser"); const ejs = require("ejs"); const homeStartingContent = "Lacus vel ..

Read more

i have got this error: Access to XMLHttpRequest at ‘http://localhost:3000/api/users/uploadAvatar’ from origin ‘http://localhost:8081’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. when my server cors options are: app.use((req, res, next) => { res.header("Access-Control-Allow-Origin", "http://localhost:8081"); res.header("Access-Control-Allow-Credentials", "true"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization"); if (req.method === ‘OPTIONS’) { res.header("Access-Control-Allow-Methods", ..

Read more