Yesterday it was working perfectly fine and I wasn't getting this error.
Tried replacing a bunch of stuff with this one single line and I'm just flat out confused on why this is occurring.
I've been researching this for an hour and all the results for 'Unexpected end of JSON input' don't really fully match what I'm doing and are incredibly confusing to me as I am fairly new to javascript.
Line that's causing it:
let userData = JSON.parse(fs.readFileSync(__dirname + '/Storage/userData.json', 'utf8'))
I should also point out that above the error it says what is causing it is 'undefined:1'??? So that's pretty weird. Normally it would show like the line in the javascript code but no, I had to search through the list of "at (something in some script)" to find what line was causing it, I have a feeling it might have to do with the JSON itself instead of my code.
The error is from the ./Storage/userData.json file. Do you have an empty file? If yes, make sure to save it with []. Sometimes, the file can be cleared by a code error who affects the data.
This happens when your .json file is empty. This is why I do not recomment sorting data in a .json file, if you edit it alot, it can sometimes be completely wiped out.
To fix it, simply put {} in the file and the error should be gone. Your data will be gone, too though.
Related
So I'm getting the following error:
Uncaught Error: Assertion Failed: The key provided to get must be a string, you passed undefined
Should be easy enough to fix, if there was any indication of the line in my code that causes that error.
Using the chrome console, I click on ember.debug.js:6254 next to the error, which just shows me the ember code that throws the error. I can expand the error, but I just get a bunch of functions that can't be clicked on and no indication where they come from.
Can someone please help me figure out how to identify the line in my Ember code that is causing the error.
I've gotten this error before. It happens when you call get() in any of its forms (Ember.get() or this.get() or get(this)) without a string as the name of the property you want to retrieve.
You should be able to find the source of the error by auditing your application for wherever you call get() and making sure you pass the property name as a string. E.g., Ember.get('model.someProp') or this.get('someProp') or get(this, 'someProp').
This should be a comment but I can't, so here goes:
Iam new to Ember and have been spending quite a long time debugging. Remember that long stack of function calls that chrome's console shows.
Look for anything other than ember.debug.js...especially those marked (anonymous function) and files with names vendor.js or app-name.js
Usually in software development when debugging your best friends are going to be console.log() or alert() (in the case of JavaScript). Usually you have to figure out if your getting what ever is that you passing to your function by consolelog everything until you find your bug. Ember sometimes will not tell you what is exactly the error because does not know where exactly is coming from.
...computers are annoying but we love them....
here are some articles from Mozilla developer and Google on how to debug JavaScript.
I had a NULL value in my database which I wasn't accounting for in my app. In my case, it shouldn't have been NULL in the first place, so after giving the record a value in my database the problem disappeared.
I agree the error message is not very helpful.
I'm using codeigniter, my program is fine in localhost but get mistakes online.
It's hard to describe but everything like pictures tell:
Even worse, if I write code in js like this:
var a='{"status":0,"message":"Operation succeed!"}';
var b=$.parseJSON('{"status":0,"message":"Operation succeed!"}');
It becomes:
And throw exceptions that I can't analyze JSON codes.
This issue is caused by the BOM at the beginning of PHP files.
After using a text editor that allows me to remove the BOMs, the problem is gone.
I don't know if this has been asked before, but what i'd like to be able to do is get data from the error console within the browser itself(if it supports it) this would be for when a user sends off a bug report it'd pull up any errors related to pages at my website for things such as typos in code and other things that somehow managed to slip by. Also, in that regard is there a way to pass the errors from the console to a useable format? If this isn't possible, then i could just tell them to copy and paste what came up from the site itself.
I thought of this right now as i was thinking about how to make the bug reporting system run better since the entire thing is basically ran within the browser and for the backend I can easily just look at error logs but for the frontend ie javascript bits of things it's not goign to be as easy.
So to finish wrap all of this up in one little statement, is there an easy way to get the data from the error console and be able to send it along via javascript ie to a form, or something similar.
You can use the onerror event in JS to get the details of the error. Hoptoad do this for example and log the errors to their console, Their code re-uses lots of nice JS scripts including a printStackTrace function that is great.....
You can see how they do it here:
http://hoptoadapp.com/javascripts/notifier.js
Come across this once in awhile.
Unpacked a zip file sent to me by a coworker. Loaded it up on my tomcat server to find out that there's this weird question mark at the beginning of the included JS file, preventing the JS file from being included properly.
I resaved the HTML file and the JS as new files and made sure encoding was UTF-8 and the line breaks were UNIX style.
Now I see the "ILLEGAL Token" error in Chrome and FF. Any ideas why?
EDIT:
Adding JS that is causing the issue. Anything inherently wrong with this? Per a comment, I think the removal of BOM fixed the issue but still getting the "ILLEGAL Token" message.
if(typeof deconcept=="undefined"){var deconcept=new Object();}
Hard to say with much confidence, but weird characters at the start of text files are very often the Byte Order Mark (BOM). See http://en.wikipedia.org/wiki/Byte_Order_Mark. Some software handles them well, and you see nothing, other software doesn't handle them correctly and you see weird characters.
I am editing an existing site, which is a typical merchant site. A series of PHP files with one main index that loads in the various content pages.
The main index.php, using <script>, loads in jsFunctions.js.
When ever I modify the jsFunctions.js file, the index only loads the jsFunctions.js partially. For example I will get a firebug error such as 'unterminated string literal' or 'missing end }' or similar. The errors themselves make sense, because the js file isn't fully loading, a brace or quote is missing and throwing an error. It is seemingly random, sometimes it will load 100 lines of the js, then sometimes 105 lines, etc.
But why would the file be partially loading if i edit it? If i remove the single line of my code, no matter how simple, it starts working again?
Any ideas?
Are you editing a file with inconsistent line-endings, which editor? Issues like line-ending or weird unicode characters cause the issues like you've described.
I would take the contents of the file after your edit do a copy/paste exact as it is to JSLint: http://www.jslint.com/
JSLint is a validation tool for your script, before checking for best practices though, it'll check that your script is valid at all. See if you get the same error, it could be a weird character that's slipped in there causing issues, JSLint will alert you to this and where it's at.
Apparently it was some kind of server serving issue. If I refreshed a random amount of times, the full js would load. Once loaded it works 100% after that, well until I uploaded a new copy, then I would have to refresh a couple of times (or possibly wait 1-2 mins).
Filezilla was showing that the upload was complete, but the server simply didn't seem ready to output it.
Thanks guys