Skip to content

Instantly share code, notes, and snippets.

@victor36max
Created July 29, 2018 09:35
Show Gist options
  • Save victor36max/28cc4f18cde8155dfc1d00719813dfcd to your computer and use it in GitHub Desktop.
Save victor36max/28cc4f18cde8155dfc1d00719813dfcd to your computer and use it in GitHub Desktop.
static async getInitialProps({ isServer, store }) {
   // Fetch today NASA APOD
   await store.execSagaTasks(isServer, dispatch => {
     dispatch(fetchApodStart());
   });

   console.log('');
   console.log('###############################');
   console.log('### Fetched today NASA APOD ###');
   console.log('###############################');
   console.log(store.getState().apod);
   console.log('');

   // Fetch custom date NASA APOD
   await store.execSagaTasks(isServer, dispatch => {
     dispatch(fetchApodStart('2018-07-26'));
   });

   console.log('');
   console.log('#####################################');
   console.log('### Fetched custom date NASA APOD ###');
   console.log('#####################################');
   console.log(store.getState().apod);
   console.log('');

   return {};
 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment