I am trying to fetch data from text file which resides on server. I have access of that location and able to see content when I put URL in browser tab. I am trying to make AJAX call and get file content, but I am getting Error: Uncaught SyntaxError: Unexpected identifier Code on console, I tried below code to…
I tried moving my JS script into a separate js file, but it stopped working once I did. How can I fix it?
I just started learning JS, and im not understanding it that well. I am not that great at coding generally, so apologies for this really barebones and very possibly wrong website, but all I wanted to accomplish at the moment was to change the websites background color when I press the button. When I did it in…
Can not access map
I get this error when I execute code ,I want to access server_queue playing TypeError: Cannot read properties of undefined (reading ‘playing’) This is my code: Answer After skipping your first if block when server_queue doesn’t exist, you are then trying to access playing on top of the nonex…
Calculation based on variable containing multiple possible substrings
I have 2 variables (source and platform) that has results such as: “Source”: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.1185.44 etc. “Platform”: Win32 etc. I want to create 2 new variables (device and system), “extracted…
Cannot GET routes other than “/” express
I’m trying to create a web app with the MVC pattern and express in node.js. This is my project structure: project structure image app.js: loginController.js: The problem is that I can access the index page (“/”) but not the login page (“/login”) even when the code for both is alm…
Adding array of value in javascript
I’m asking this question again and hope I get the answer this time, I have an array of number that adds and subtract on button click which works withonclick and a function created. I will like the sum up of the array 21998 and 11999 when this same button is click and will like to display the value in &l…
Reading PORT number from .env file in nestjs
I have details defined in .env file. Below is my code. host: process.env.SMTP_HOST is working properly. but when I am writing process.env.SMTP_PORT it is saying you can not assign string to number. when I wrote parseInt(process.env.SMTP_PORT) it is still not working. how to assign port from .env file Answer p…
Reactjs/Nextjs onClick event not working for external component
I have a main page, with a button component i create to reuse in my project. My issue is when i add the onClick event to my external component, the click event is not working, but is i create the same button inside my main page, the click event works just fine Button Component This works on main page Button
How do I keep the state of a React Component after removing others from an array?
I’m new to React and am not sure what I’m doing wrong here. I have a component called Blocks that contains an array of sub-components in state. Right now, when I add the sub-component Paragraph, I do so like this. This is in the parent component Blocks. The Paragraph component has a state variable…
Get data from RichSnippet JSON and set the same string into other variable
I have this JSON generated from external (Reviews-io) script: https://widget.reviews.co.uk/rich-snippet/dist.js I need to get all the string of numbers in “sku”, and then put them in another variable as same format (6647; 6647_1; 6647_2) I try to get the numbers using this JS but doesn’t wor…