express

Angular 7.x query to node express server is converted to an object array of characters

若如初见. 提交于 2020-01-16 14:18:12
问题 I am sending a query string to a node express server. When I access the req.query property it is an array of characters instead of a normal object or the string I sent. Any Ideas? Query sent const data = await this.cspCrudService.findOne(stringQuery); service findAll(params: any): Promise<T[]> { THIS LINE BELOW WAS THE PROBLEM const query = StringUtil.toMongoQueryString(params); return this.httpClient.get<T[]>(`${this.url}${this.endpoint}/${query}`).toPromise(); } "location[$regex]=^F

Node.JS Unable to call a service running on localhost on different port

99封情书 提交于 2020-01-16 14:08:13
问题 What i am trying to do is that that my application is running on localhost on port 3030 i have written this code var request = require('request'); request("http://127.0.0.1:3000/showdb", function (error, response, body) { if(error) console.log("ERROR IS :"+error); if (!error && response.statusCode == 200) { console.log("body"+body) // Print the google web page. res.send(body); } }) so i am calling another service of application running on port 3000 on my localhost.(127.0.0.1 default ip for

Nodejs with nginx CSRF verification failed. Request aborted

拥有回忆 提交于 2020-01-16 12:06:30
问题 I am new to nginx, i manage to run multiple Nodejs projects on single server with different ports. I used my domain to call my Nodejs apis. when I try to call my api from android error is throwing. if I replace domain with IP address all api cals are working fine. with domain name api call it shows Forbidden (403) CSRF verification failed. Request aborted. You are seeing this message because this site requires a CSRF cookie when submitting forms. This cookie is required for security reasons,

Nodejs with nginx CSRF verification failed. Request aborted

吃可爱长大的小学妹 提交于 2020-01-16 12:06:09
问题 I am new to nginx, i manage to run multiple Nodejs projects on single server with different ports. I used my domain to call my Nodejs apis. when I try to call my api from android error is throwing. if I replace domain with IP address all api cals are working fine. with domain name api call it shows Forbidden (403) CSRF verification failed. Request aborted. You are seeing this message because this site requires a CSRF cookie when submitting forms. This cookie is required for security reasons,

How to retrieve currentUser data with Vue.js, Vuex, Express, MongoDB

耗尽温柔 提交于 2020-01-16 12:04:17
问题 I am attempting to build a MEVN stack authentication page that returns information on the currently logged-in user. Upon logging in, the router re-directs to the Home.vue while passing the username to the Home.vue as a prop. onSubmit method in Login.vue <script> methods: { onSubmit (evt) { evt.preventDefault() axios.post(`http://localhost:3000/api/auth/login/`, this.login) .then(response => { localStorage.setItem('jwtToken', response.data.token) this.$router.push({ name: 'BookList', params: {

How to retrieve currentUser data with Vue.js, Vuex, Express, MongoDB

不打扰是莪最后的温柔 提交于 2020-01-16 12:02:28
问题 I am attempting to build a MEVN stack authentication page that returns information on the currently logged-in user. Upon logging in, the router re-directs to the Home.vue while passing the username to the Home.vue as a prop. onSubmit method in Login.vue <script> methods: { onSubmit (evt) { evt.preventDefault() axios.post(`http://localhost:3000/api/auth/login/`, this.login) .then(response => { localStorage.setItem('jwtToken', response.data.token) this.$router.push({ name: 'BookList', params: {

How to disconnect a client for being inactive in chat for a specific time (socket.io, javascript)

夙愿已清 提交于 2020-01-16 09:41:30
问题 In this chat app I want the server to disconnect clients who's been inactive for x (configurable) amount of time. I think the default is 60 sec, I think I should use page Timeout as you can see in my server file but not sure how to make it work. The idea is to have a timer for let's say 2 minutes of inactivity and you get kicked out with a message appearing afterwards in the feedbackBox function in name.js file. My code is below: server.js const PORT = 3000; const io = require('socket.io')

How to implement twitter and facebook api like cursor based pagination in mongodb in nodejs using official mongodb client?

大兔子大兔子 提交于 2020-01-16 09:12:08
问题 I am trying to implement pagination which should not show duplicate data in different pages on data insertion or deletion. Basic offset-based approach using skip and limit to paginate data is given on this How to implement pagination for mongodb in node.js using official mongodb client? Offset-based approach has a big flaw: if the results list has changed between calls to the API, the indices would shift and cause an item to be either returned twice or skipped and never returned This problem

Setting Cache-Control pubic not caching xhr

爱⌒轻易说出口 提交于 2020-01-16 08:54:08
问题 I am trying to implement caching for XHR reponse with in theory the browser should go to server, and server can decide to send 304 - Not Modified if there is no new dynamic data and the browser would use the cache response from its previous request. As per the theory, it could be done using no-cache on Cache-Control . But first I tried to use, if at all I can make the browser store the response by setting response.set('Cache-Control', 'public, max-age=315360000, max-stale'); I can see, it in

Trying to delete comments and end up deleting post and not comment using REACT/NODE/EXPRESS/MONGODB

房东的猫 提交于 2020-01-16 08:47:14
问题 The problem here is that I am trying to delete a comment and instead it deletes the post it belongs too. I have checked to make sure I am not calling the wrong function somewhere, but I can't seem to find that I am. I am not sure if this is wrong coding on the front or back-end. I will separate the code from server and client and also try to make it clear what does what. I am using react for front side and node/express/mongodb for my back-end. As I usually do if you request more information