When calling fetch(local_url)
from a stimulus controller, I can see the Rails controller’s js response returned in the browser dev tools, but this javascript is not executed. If I copy and paste the js response and run it in dev tools, it runs as expected.
Is there some restriction on making a fetch()
request from a stimulus controller, that prevents the js response executing?
E.G. the Rails js template contains just alert("hello");
I can see this in the response but there is no alert.
I did add protect_from_forgery except: :show
in the controller, which prevents the CRSS error