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

Empty response in fetch of child RouteHandler #44

Closed
EJIqpEP opened this issue Jun 17, 2015 · 4 comments
Closed

Empty response in fetch of child RouteHandler #44

EJIqpEP opened this issue Jun 17, 2015 · 4 comments
Labels

Comments

@EJIqpEP
Copy link

EJIqpEP commented Jun 17, 2015

Hello guys. I modified code a bit. And I have no success fetch in ProjectLessonsListroute in server side. With javascript enabled in browser everything is ok.
My console.log is
suxx {'0': {}} and component is not rendering at all.

_Main.js_

  render () {
    return (
      <div>
        <h1>Main</h1>
        <RouteHandler/>
      </div>
    );
  }

_Routes.js_

export default (
  <Route name="app" path="/" handler={Main}>
    <Route name="ProjectLessonsList" path='/project/lessons' handler={ProjectLessonsList}/>
  </Route>
);

_ProjectLessonsList.js_

import __fetch from "isomorphic-fetch";
import React from 'react';
import Transmit from "react-transmit";
class ProjectLessonsList extends React.Component {
  componentWillMount () {
    console.log('mounted project lessons', this.props.lessons);
  }

  render () {
    return (
      <div>
        <h1>ProjectLessonsList</h1>
      </div>
    )
  }
}

export default Transmit.createContainer(ProjectLessonsList, {
  queries: {
    lessons (queryParams) {
      return fetch('https://api.github.com/repos/RickWong/react-isomorphic-starterkit/stargazers?per_page=100&page=1')
        .then((resp) => {
          console.log('suxx', arguments);
          return resp.json();
        })
        .catch((err) => {
          console.log('err', arguments);
        });
    }
  }
});
@EJIqpEP
Copy link
Author

EJIqpEP commented Jun 26, 2015

What if I want to get some data from backend on login page? As I understand I need to export Transmit.createContainer. But it doesn't work as I expected.

@kalken
Copy link

kalken commented Jun 26, 2015

Yes I might have miss-understood your question so i removed my answer.

@kalken
Copy link

kalken commented Jun 26, 2015

look here: #30

@EJIqpEP
Copy link
Author

EJIqpEP commented Jun 26, 2015

Wonderful. Thanks for this link. I couldn't find it. The problem is solved

@EJIqpEP EJIqpEP closed this as completed Jun 26, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants