Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Is there a way to wait for API response before server will render a page? #14

Open
kuatro opened this issue Oct 3, 2016 · 14 comments
Open

Comments

@kuatro
Copy link

kuatro commented Oct 3, 2016

Hello!
I found that server isn't waiting for async API response, and sends blank components to front-end.

@janoist1
Copy link
Owner

janoist1 commented Oct 4, 2016

Hi! I'll have a look at it soon, probably tomorrow.

@kuatro
Copy link
Author

kuatro commented Oct 6, 2016

What do you think about this approach?
bananaoomarang/isomorphic-redux

The only confusing thing for me is adding a needs array to each container.

@janoist1
Copy link
Owner

janoist1 commented Oct 7, 2016

I'll check it later in the weekend and come back to you. Thanks for the link.

@janoist1
Copy link
Owner

janoist1 commented Oct 9, 2016

I've checked it. It's a nice solution, I might implement it into this starter kit once I have some time. ;-)

@bodyno
Copy link

bodyno commented Oct 19, 2016

also have the same question

@kuatro
Copy link
Author

kuatro commented Oct 19, 2016

@bodyno I think we could help @janoist1.
Currently I'm working on integration redux-saga in this boilerplate, but I haven't much free time.
Could you implement something like the example that I've posted above?

@bodyno
Copy link

bodyno commented Oct 19, 2016

@kuatro
I'm not so familiar with the universal react.
Please tell me how to call dispatch action at server side.

@janoist1
Copy link
Owner

janoist1 commented Oct 19, 2016

It looks like I'll have some time in the upcoming weekend, will try to implement an async example and do some general updates. ;)

@bodyno
Copy link

bodyno commented Oct 19, 2016

👍 👍 👍

@bodyno
Copy link

bodyno commented Oct 19, 2016

@janoist1 Please just give me some train of thought
how to call dispatch action at server side

@janoist1
Copy link
Owner

janoist1 commented Oct 24, 2016

@bodyno I'm not sure what you wanna achieve but guessing you want a point where you can initiate your (async) API request. I chose route onEnter callback as starting point:

import Weather from './containers/WeatherContainer'
import { fetchWeatherData } from './modules/weather'

export default store => ({
  path: 'weather',
  component: Weather,
  onEnter: () => {
    // async get weather data
    store.dispatch(fetchWeatherData())
  }
})

I'm working on an async example that runs on server side. I'm not far from getting it done. ;-)

@peterpme
Copy link

@kuatro if you can show me exactly what needs to be done, I'm personally interested in fixing this and don't mind submitting a PR to make it happen

@kuatro
Copy link
Author

kuatro commented Nov 16, 2016

Hey, @peterpme .
As I understood, when you build an isomorphic React/Redux app, you need to implement your own promise middleware to resolve all API requests on server-side.
I've sent a link above: bananaoomarang/isomorphic-redux

@peterpme
Copy link

@janoist1 mind closing out this issue and direct folks to #19?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants