3 ms·
If you are using jsonp (?callback=foo) then return a 200 and embed the response code in the response. foo({"err":{"code":500,"msg":"oh no. i broke!"},"respon
by stock_toaster 15y ago
If you are using jsonp (?callback=foo) then return a 200 and embed the response code in the response.
foo({"err":{"code":500,"msg":"oh no. i broke!"},"response":null})
foo({"err":null,"response":"hooray"})
If not using jsonp, then use the status codes IETF gave you. ;)
Most frameworks (WSGI, Rack) allow you to wrap the response and check for presence of the callback, and transform into a friendlier jsonp format. Then you can simply ignore it and code as normal. In this case, doesn't express (seems to be what you are using?) support route middleware too?