Skip to content

Instantly share code, notes, and snippets.

Created May 13, 2018
What would you like to do?
Sometimes I find it handy when I'm developing a single page app to have all front-end errors forwarded to the backend's log (when something doesn't work, I can look in a single terminal window)
const puts = (...anything) => {
fetch("/api/puts", {
method: 'POST',
headers: {
'Content-Type': 'application/json'
body: JSON.stringify({content: anything})
window.onerror = (message) => {
puts('JS Error:', message)
return false
module Api
class PutsController < ApiController
def create
puts <<~TEXT
Client logger says:
#{params[:content].map(&:to_json).join(", ")}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment