I want to get started with vue.js but there is NO mention of how to get data from a database. It is assumed the reader knows exactly what to do.
What you described is basically how I imagined it would work but I've just not been in this world for so long that I haven't been able to find the answer. (How to get data from a database with a system like vue.js.)
Libs like vue & react are essentially ui renderers, they create the html representation of app state, and handle all the DOM event binding and whatnot for you.
You will likely have some kind of client state management to take care of telling your ui to update, but essentially you will push json into that 'store' and that will then be used by your framework of choice to populate the page with content.
How that json gets there is largely upto you, and will be influenced by what you use to manage state, however you will need to handle getting data from the db server-side. Php or rails are popular, with reams of great (and some not so great) resources out there, but realistically you could use whatever you wanted.
Node.js is nice and could be useful if you want to focus on 1 language initially.
Partly I was tripped up because I have used Meteor and they handle everything for you. Before that I was using PHP and making SQL queries to MySQL directly.
In both of those cases I was able to get directly at the database. What you're saying is that I need a middle-tier that acts as the layer above the database but below the client (obviously.)
You mentioned Node.js. I know what that is and I know it's not a database. So it needs to connect to a database and then pass off data to the client. This is the piece of the puzzle I'm missing in my mental visualization.
I've learned that Laravel works well with Vue so I'll start there.
Thanks!
function ensureServerUrl(url) {
// parse and replace with your server url
// in Este you read from a SERVER_URL environment variable
}
function fetch(url, options) {
url = ensureServerUrl(url);
return fetch(url, options);
}In the case the GP describes, the proxying web server has no additional authority on the API server: if the API route requires a cookie from the user, it doesn't matter whether that's passed directly or proxied.
That being said, feel free to correct me if I'm missing something. Also, thank you very much for giving me the name for this problem, it will come in very handy.
How would you do that without breaking the whole universal/isomorphic aspect of this?
Some explanation at [3] although that writeup (and this demo code) needs updating.
[1] https://github.com/firasd/react-server-tutorial/blob/master/...
[2] https://github.com/firasd/react-server-tutorial/blob/master/...
[3] https://medium.com/@firasd/quick-start-tutorial-universal-re...
That entirely defeats the purpose of an isomorphic/universal React application.
But what if my component looks like this: