R
R
roskom_nadzor2016-12-05 20:36:47
API
roskom_nadzor, 2016-12-05 20:36:47

How to communicate with DB in React Universal Apps?

I had my eye on universal (isomorphic) SPAs, but in all boilerplates there are no adequate examples of working with SQL databases, such as Postgre.
Usually they suggest doing this: you do the "frontend" separately, the api separately. What is meant? The fact that on one server there should be this very application, where the server acts as a renderer and a proxy to the api server. And on the other hand, the API server in which the database + microservice.
I think that this is an overkill and we need a way to communicate with the database without unnecessary abstractions, since a public API is not needed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aves, 2016-12-05
@roskom_nadzor

Where is this offered? It seems the other way around, everything is on the same server and the usual approach is this:

Component {
  state = Object.assign({}, this.props.initialState);
  componentDidMount() {
     fetch(...).then(data => this.setState(data));
  }
  ...
}
render on client:
render on server:
And SPA without api is something strange.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question