thealphadollar / messiah

Messiah: The Mighty Son Of God Is Here To Help You Through Times Of Calamity
https://messiah-cfd.herokuapp.com/
GNU General Public License v3.0
2 stars 0 forks source link

Bug in dashboard.html, JSON parse error #53

Closed swghosh closed 5 years ago

swghosh commented 5 years ago

Minor bug in src/frontend/dashboard.html

The JavaScript console when loading the dashboard, reports error.

[Error] SyntaxError: JSON Parse error: Unexpected EOF
    parse (dashboard.html:228)
    onreadystatechange (dashboard.html:228)
[Error] TypeError: undefined is not an object (evaluating 'data["results"][0]["geometry"]')
    onreadystatechange (dashboard.html:229)
[Error] SyntaxError: JSON Parse error: Unexpected EOF
    parse (dashboard.html:199)
    onreadystatechange (dashboard.html:199)

Problem

The javascript code snippet uses two AJAX requests to get JSON(s) from the backend server. Although, the backend API server returns JSON in correct form, error is raised during parse at client-side.

Workaround

Relevant fix request's function onreadystatechange should check for this.status == 4 && this.status == 200 and only then perform further actions

Refer to: https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX/Getting_Started#Step_3_–_A_Simple_Example

knightcube commented 5 years ago

May I work on this?

theartist007 commented 5 years ago

Actually, this issue is labeled KWOC, which means we have put it for students of Kharagpur Winter of Code program, to solve. U can surely be a part of KWOC, and then solve this, if you already aren't. @knightcube

knightcube commented 5 years ago

Yes I am a participant of KWOC. Could you please tell me how can I fix this issue?

theartist007 commented 5 years ago

@swghosh has written a possible fix of the issue, in the description. You can go on his lines, or think about it yourself how to do it. The README.md file has the complete description of the project.

knightcube commented 5 years ago

I read the suggested fix and I am implementing it. Kindly tell me if I am going wrong. This is what i am doing currently - 1) 1st if block contains Lines 197 to 204 2) 2nd if block would contain Lines 227 to 234 and the if condition will be - if(this.status == 4 && this.status == 200)

swghosh commented 5 years ago

Absolutely @knightcube Just test it once whether the bug is fixed after that or not. There's a reference link too.

theartist007 commented 5 years ago

Yes @knightcube , its absolutely fine. Go for it. U can join my kwoc project channel : https://gitter.im/kwoc-messiah/Lobby, if you want to work further, on this project.

knightcube commented 5 years ago

Already there :)