Logging properties of Node.js - javascript

I'm starting on a project using Node.js, and I'm running into some issues with it's logging. I'm completely new to Node.js, but my understanding is that using console.log([data]) should print out the value of [data] to the server console.
I see this occurring how I expect in several places in this project, but when I try to add additional logging, nothing is prompted out to the console window.
I've noticed that all of the files where logging is working are under a specific folder, while the bulk of the code is under another.
Does anybody know what might be the cause of these not to print out into the console? I've also tried console.error([data]) and console.warning([data]) to see if it might be due to an error but that also didn't work.

Without having your actual code, this is just a guess:
The files where the logging is working are the Javascript files for the server. The "bulk" of the code may be the client code (I guess so because you're saying in the comments of your post that you inserted a working alert, which is a browser thing), so your logs go to the browser not to the server.

Related

how does a browser know if a javascript is from webpage or a client user has written them?

javacript can be served to browsers that comes from server. but we can also write javascript code in the browser console. so my question is how does a browser know that javascript is written by end user or it has come through webpage. is there some sort of ownership mechanism or stack implementation?
can i perform xss attack from brower console. if not then why?
i have just encountered a situation where a function was not defined inside a webpage script so throwing error. then i defined that function in browser console and then error changed to something else. (the whole code was written by me, website was mine too. but on a proper domain and is in production)

How to prevent payload of array got replaced by string of html on react redux reducer?

So, I experienced weird things about my website. I already deployed my website to Heroku. All the GET request suddenly doesnt work, but all the POST request works just fine. But, when I run my website locally on development mode, it works for all the request type.
I guess its caused by my redux payload. Because, when I run my website on development mode, (look at the console of my redux dev tools), the payload of the contents array filled with an array of object, but when I run my website on production mode, the contents array got replaced to some sort of HTML string. How do I fix this?
Oh, by the way, the contents array is the one that the website has to map, and because it got replaced by a string, the website couldn't map it, so it shows the error.
These are the screenshots and source codes so you guys can better understand:
Screenshots:
Development Mode
Production Mode
The error
Source Codes:
contentReducer.js
contentAction.js
Timeline.js
and this is my website in which I am getting error: InfoTech

XMLHTTPRequest Status 0 In Unusual Circumstances

I've been working on an AJAX script to perform some simple test manipulations via the Node.JS MongoDB driver. This script is causing me no end of headaches, for the following reasons:
When I run the script natively in the node.js command prompt, it runs to completion, and performs all of the operations I intend it to. A full trace of its activity in Chrome's Node Inspector reveals that it does indeed perform as intended.
Having debugged the script via Node Inspector, I then wrote a simple test page to call that script via AJAX. Despite taking care to use proper asynchronous callbacks, the script appears to hold up the server for an inordinate period of time, and returns with an HTTP status code of 0.
Having searched Stack Overflow for similar issues, the threads I surveyed all issue the same message - that this is a CORS problem. BUT ... if this was a CORS problem, NONE of the other AJAX scripts in the same directory would work, and would presumably return the same HTTP status code of 0.
Firing up a new, simpler test script to see if MongoDB connections are somehow interfering with my node.js server, this new script did NOT trigger an HTTP status code of 0, but instead returned as expected, with the HTTP status code of 200. This new test script resides in the same directory as the troublesome script, so it can't be a CORS issue.
Likewise, experimentally calling other scripts in the same directory via AJAX yields the same result - all the other scripts return HTTP 200 as expected.
So, why is this one script returning with an HTTP status of 0, while every other script in the same directory returns with an HTTP status of 200?
At this point, no doubt people will ask me to show the code. However, there's a slight problem. The script in question is 749 lines long, and I suspect that [1] it'll be impossible to pinpoint the error without embedding the entire code file in this question, and [2] numerous individuals will berate me for doing so. The fact that the script runs without errors in Node Inspector also makes this puzzling. I can edit this question and include all of that code if asked, but given what I've stated above, I have no idea where to begin pinpointing the error in that code, so there's no way I can select parts of it that might be problematic, especially in the light of the fact that it runs to completion, without error, in Node Inspector via the node.js command prompt.
Just in case this issue is platform specific, I'm running Node V8.11.3 LTS and MongoDB 4.0 on Windows 7 64-bit.

SP page deployed, but the content is old

I have a simple setup - SharePoint Foundation Server and Visual Studio 2013 Professional installed on this server. Everything worked fine. Until... I don't know why, but deployment stopped refreshing content on the page.
I have some javascript code on my page (inside aspx page or in external js file). When I change it (e.g. output sth else to console) I still see the effect of some previous build. It looks like deploy operation does nothing. The most puzzling part I think is when I click Debug button. One would expect it to work at least there. But it doesn't.
Two other developers working on the same environment (same server) have no problems with changing their JS code.
The only hint I have is this error msg:
0x80070005 - JavaScript runtime error: Access is denied.
I see it when I run Debug from VS. It is thrown at line if (!IsNullOrUndefined(window.localStorage) && IsNullOrUndefined(window.localStorage.SPAnimationEnabled)) of core.debug.js file from SP core.
Can anyone help me? I don't even know how to google it :s
Oh, I should also mention that I did clean and rebuild all but nothing helped. Also there are no errors thrown - either on VS output or in event viewer.
The project was under svn, so I fixed it by checking out to other directory. And it works just fine. I guess it had sth to do with permissions.

Create ActiveXObject on *server*

I have created a little html stub that allows a user to compare various spellers. I would like to include the Word speller and I have written code in a .js file to create an ActiveXObject thus:
var wordApp = new ActiveXobject("Word.Application");
This works fine on my local machine but I get the dreaded 'Automation server can't create object' error when I try it on other machines. I have searched and read the various articles on the topic and I understand that what I am trying to do is very,very bad, not safe, doesn't work on any browser than IE, and so on. This is for an internal test app in a trusted environment and all I want is for others to be able to access the page and see the result without forcing them to make extreme changes to their security settings.
So, here is my question. Is there a way that I can get this to run server side on my machine running IIS and hosting the website? Ideally I would like to be able to insert my HTML into an aspx file and, when the submit button is pushed, have it either run all the javascript on server side or at least run the portion that calls the activeX code. If this isn't feasible, can I migrate the specific functions that call the activeX and get the data to C# or VB and still run the safer functions in JS?
Thanks for your advice!

Categories

Resources