Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting JSON error in node enviroment #508

Open
spmsupun opened this issue Aug 9, 2021 · 7 comments
Open

Getting JSON error in node enviroment #508

spmsupun opened this issue Aug 9, 2021 · 7 comments

Comments

@spmsupun
Copy link

spmsupun commented Aug 9, 2021

I am getting JSON error when WS retrieve data from backend, so I debug the frontend js and I am getting a invalid json:

{ 
  "moduleName": "current_ram",
  "output": "{ "total": 15853.7, "used": 13733.4, "available": 2120.32 }" 
}

image
image

Am I doing something wrong?

@VigneshVaidyanathan
Copy link

It is an error when the JSON values get parsed. I made the following changes and it worked.

index.js
Modified line 58
from var wsResponse = '{ "moduleName": "' + moduleName + '", "output": "'+ output.join('') +'" }'
to var wsResponse = '{ "moduleName": "' + moduleName + '", "output": '+ output.join('') +' }'
reason
The extra " double quotes surrounding the output property value, messed with the double quotes inside the actual value. So I removed it to so it can be directly converted to an object.

server.service.js
Modified line 36 -
from var moduleData = JSON.parse(response.output);
to var moduleData = response.output)
reason
Made the change so when the websocket client listens to the data being passed, it should not try to parse the already parsed output property.

If you have edited the changes in the server.service.js then build the source and copy the linuxDash.min.js to the server. You could also directly update the linuxDash.min.js and index.js on the server and everything will start working.

I have not done any tests or verifications to make sure things do not break in other implementations like Python etc, but my app started showing everything after that.

Let me know if it works for you.

@spmsupun
Copy link
Author

spmsupun commented Oct 2, 2021

I have already chosen a different one, It's been so long 😅

@VigneshVaidyanathan
Copy link

@spmsupun Out of curiosity, which dashboard do you use now?

@spmsupun
Copy link
Author

@VigneshVaidyanathan i use netdata

@VigneshVaidyanathan
Copy link

Installed it. There is no turning back now, is it. It looks awesome 😄

@spmsupun
Copy link
Author

yeah, I thought it's heavy but no, its super light weight

@DanZai233
Copy link

@VigneshVaidyanathan it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants