brokkoli_origin has quit [Remote host closed the connection]
brokkoli_origin has joined #ruby
xlymian has joined #ruby
xlymian has quit [Ping timeout: 260 seconds]
xlymian has joined #ruby
xlymian has quit [Ping timeout: 240 seconds]
xlymian has joined #ruby
xlymian has quit [Ping timeout: 260 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 252 seconds]
xlymian has joined #ruby
jenrzzz has joined #ruby
user23 has joined #ruby
Paris has joined #ruby
Paris has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 252 seconds]
Paris has joined #ruby
Paris has quit [Remote host closed the connection]
Paris has joined #ruby
user23 has quit [Remote host closed the connection]
Paris has quit [Remote host closed the connection]
Vonter has quit [Ping timeout: 255 seconds]
Vonter has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
Festive_Derg is now known as A_Dragon
Vonter has quit [Ping timeout: 240 seconds]
Vonter has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
egality_ has quit [Remote host closed the connection]
xdminsy has quit [Read error: Connection reset by peer]
jenrzzz has quit [Ping timeout: 245 seconds]
xdminsy has joined #ruby
myappie has quit [Ping timeout: 240 seconds]
desnudopenguino has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
szkl has quit [Quit: Connection closed for inactivity]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
wryish has quit [Quit: %blank%]
jenrzzz has joined #ruby
wryish has joined #ruby
Rovanion has quit [Ping timeout: 252 seconds]
Rovanion has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
Guest48 has joined #ruby
Guest48 has quit [Client Quit]
jenrzzz has joined #ruby
_ht has joined #ruby
jenrzzz has quit [Ping timeout: 276 seconds]
Paris has joined #ruby
rvalue has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 252 seconds]
rvalue has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
Paris has quit [Remote host closed the connection]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 252 seconds]
ionface has joined #ruby
jenrzzz has joined #ruby
Req has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
Req has quit [Ping timeout: 245 seconds]
Req has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
Vetheon has joined #ruby
Vetheon has joined #ruby
Vetheon has quit [Changing host]
<Vetheon>
If anyone is familiar with Sinatra, I'm trying to pass a set of data fetched from a DB from the backend to the JS on the frontend to draw a chart with it. I'm getting the right response out of everything until I'm trying to actually use the data. When logging to the browser console, it shows the data is null, but when looking at the response in the Network tab, it shows that it's properly returning the
<Vetheon>
data. Any ideas? Let me know what code/logs you need to see and I'll pastebin them up for you
<ox1eef_>
Vetheon: Do you obtain the data with window.fetch ? Is it JSON ? Do you: fetch(...).then((res) => res.json()) ?
cek has joined #ruby
jenrzzz has joined #ruby
<Vetheon>
so, the Sinatra backend fetches the data from the database: (main.rb) https://pastebin.com/f4xJHCRH Then it should get passed to the ERB template partial: (_overall_network_status.erb) https://pastebin.com/giQ1NqFk which is where the JS should get it, and where the problem is [I think?]: (overall_network_status.js): https://pastebin.com/qB8qQn96
<ruby[bot]>
Vetheon: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
<Vetheon>
Well sorry bot, I don't trust Github and don't know a better pastebin.
<ox1eef_>
Are you sure the JSON is in the format: {'data' => ...} ? It seems that key does not exist.
<Vetheon>
I mean, it potentially doesn't I suppose. I guess in the database it doesn't have a key like that, so in the converted object it wouldn't either
<Vetheon>
If that's really the problem, I'm gonna fricken break my own toe off man
<Vetheon>
Ok, so I'm still running into the same issue. It's strange, the Sinatra logs prove the object exists, and is now formatted properly. However, in the browser console it says: Current Status Data: null overall_network_status.js:4:13Historical Status Data: null overall_network_status.js:5:13
<Vetheon>
Which means the JS still isn't getting the data
<ox1eef_>
Log the then after res.json(), eg: console.log(currentStatus)
<ox1eef_>
And, don't forget to update the JSON route. You have upodated HTML AFAICT.
<Vetheon>
Oh yeah, I'm just silly, the JSON object still isn't formatted properly: https://snippet.host/ujeguo
<Vetheon>
The overall problem here is that the JS isn't getting the data, which means my charts aren't drawing. It was working fine before I tried to implement an auto-refresh mechanism so you don't need to refresh the page to get new data
jenrzzz has joined #ruby
<ox1eef_>
So you throw an error, which means the data key is still not right ? I think you want to update DataFetcher class, so that you return {'data' => result}.
<ox1eef_>
When the array is empty, return early rather than throw. Now I question whether it is the change you made to the HTML view which is the problem. That worked before, right ? But indeed, it seems one problem is solved, and now there is a different one.
<Vetheon>
Yeah, everything worked properly before. Basically, it was all working, and pulling from the database properly. Then I changed to refresh the data on a cycle without the user needing to refresh the page manually. Which means AJAX nonsense. Which is when everything broke.
<Vetheon>
No idea if my prev messages sent or not... but in synopsis. Tried to use <%== instead of <%=, no change. Starting to consider just making a external API for it
xlymian has quit [Ping timeout: 240 seconds]
jenrzzz has quit [Ping timeout: 256 seconds]
<Vetheon>
Well, time to reboot. Kernel updates yayyyy
Vetheon has left #ruby [#ruby]
infinityfye has quit [Read error: Connection reset by peer]
EternalSunshine has quit [Quit: WeeChat 4.1.2]
schne1der has quit [Quit: schne1der]
passbe has joined #ruby
<weaksauc_>
seems like it could be some kind of rendering an empty array based on the second array object being spit out
c10l has quit [Remote host closed the connection]
c10l has joined #ruby
reset has quit [Quit: reset]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
cek has quit [Quit: Connection closed for inactivity]