Closed
Description
Our docs explain how to Inject Data from the Server, but this doesn't translate well to development.
I think we should expand the docs to explain what to do in development or add means of specifying these values in development mode.
Right now I just live with the error and do something like this:
if (window.ActiveDirectoryGroups === undefined) window.ActiveDirectoryGroups = ['devmode']
This will be annoying for people using this suggested method when the error dialog is merged (if they're currently ignoring the error).
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
Timer commentedon Mar 3, 2017
I'm going to tag this for 0.10 just so we don't forget, but if this is unactionable that's fine too.
evenchange4 commentedon Mar 20, 2017
How about using try-catch so that we can handle it safely in development?
gaearon commentedon May 11, 2017
Retagging to clean up 0.10.
peterbe commentedon Jun 16, 2017
Another idea is to use a script src. E.g.
<script src="data.json"></script>
(careful about ordering and 'async' attributes). In dev mode, that'd queryhttp://localhost:3000/data.json
which would probably404 Not Found
(unless it's proxied). In production you'd have your web server pick that up and respond something likeThen the web server doesn't need to do some something like this:
Vadorequest commentedon Jun 16, 2017
@peterbe I guess you mean a data.js file? I doubt we can load JSON through
script
, never saw that before.leoskyrocker commentedon Jul 10, 2017
@peterbe Wouldn't that require another request to the server?
cr101 commentedon Jul 10, 2017
@LeoI11 Be aware that injecting data from the server has a major drawback as it will not allow search engines to properly analyze the static HTML.
piotr-cz commentedon Oct 26, 2017
Data injected with proposed <script> tag won't be cached with serviceworker in production and won't be available when offline.
My current approach is:
index.html
App.js