First of all, I want to show you my directory tree: I have tried to add types on my NodeJS project by adding Typescript. For that, I have installed many things into the root folder: npm i -D typescript npm i -D @types/node npm i -D @types/express See there the index.ts script into the dir1 folder: To test typescript compiler
Tag: express
Cookies headers are present but Cookies are not stored in browser
Please help me to figure out why the browser (Chrome and any others) does not set cookies, while Set-Cookie header is present in Response Headers: My app running at: http://localhost:8080 Answer You seem to be using CORS. To set a cookie with CORS you’ll need to set the withCredentials flag when making the request. https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials The server will need to
What is axios rate limit?
Does anyone know’s the rate limit of the axios api because it is throwing a lot of 429 errors when i am using it here is my codes Answer Axios is an Http Client. Http Clients won’t have a rate limit. However, API’s typically have rate limiting implemented (especially public onces). The error message you’re receiving is saying the following:
How can I put input value to the JSON in node.js file
I was making the TODO list web application. This is the ‘todo.html’ code below : And this is the ‘app.js’ file below : I want to pass the text box value to the JSON filter by ‘TODO’ and ‘COMPLETED’. If I add a new TODO list, it goes to the JSON and if the value goes to COMPLETED, it also
extend existing API with custom endpoints
I’m creating an API for multiple customers. The core endpoints like /users are used by every customer but some endpoints rely on individual customization. So it might be that User A wants a special endpoint /groups and no other customer will have that feature. Just as a sidenote, each customer would also use his own database schema because of those
Pass an object with JS throw new Error in node
I want to throw an error in my node application as follows. this give me the following output. I can’t access the properties of this error object. What am I doing wrong here? Answer The constructor for an Error object expects a string, not an object (which is why your scheme doesn’t work). You are free to add your own
Async/await in Nodejs + Mongoose
I’m new to Promises and async/await programming and I am not sure I am getting it straight. I am creating an API in Nodejs, with Express, Mongoose and MongoDB. I have seen a lot of tutorials on how to deal with asynchronicity but all of them are about NodeJs projects where the routing and the DB query are in the
How to Fetch and Display an Image from an express backend server to a React js frontend?
I’m trying to fetch images from an express backend and display them in the react js frontend. How can I achieve this perfectly? I have tried to fetch the images saved in my backend folder named “Backup” and display them back to the user in the react js frontend. I have tried this using axios but still am getting an
How to Insert bulk Array of data in mssql table using nodejs
I am using node-mssql, LInk : https://www.npmjs.com/package/mssql i want to insert bulk array of data in mssql database i am getting array of array records eg: [[row1],[row2],[row3]] i want to insert these records in mssql database Error : The label ‘@’ has already been declared. Label names must be unique within a query batch or stored procedure. Answer Use bulk
res.setHeader(“Set-Cookie”, …) is not setting the cookie in Node / Express
I have tried and and I have tried to set the cookie outright with but no cookie is set when I examine the res, and no cookie is received in my frontend. Everything is run locally. I do not understand why. Answer I found the answer. When using fetch() from the front end I didn’t set the credentials flag to