Question:
How can I send the client a custom json message?
Repl link:
https://replit.com/@totallygoogledrive/authforhh-ruby#index.html
In my main.rb file I have
post '/login' do
request.body.rewind
data = JSON.parse(request.body.read)
username = data['username']
content_type :json
{ message: 'success' }.to_json
end
This is supposed to log the username, and return the message success to the frontend.
This is what I have in the JS:
document.getElementById('y').innerHTML = response.message;
This takes the json response from the server and puts it into an HTML element.