src/views/ListDetail.js
/**
     * Return a Promise of the previous stargazers + the newly fetched stargazers.
     */
Return a Promise of the previous stargazers + the newly fetched stargazers.
Return a Promise of the previous stargazers + the newly fetched stargazers .
allStargazers (queryParams) {
      let githubApi = `http://localhost:8000/api/github`;
      if (__CLIENT__) {
        const {hostname, port} = window.location;
        githubApi = `http://${hostname}:${port}/api/github`;
      }
      return fetch(
        githubApi + "/repos/RickWong/react-isomorphic-starterkit/stargazers" +
        `?per_page=100&page=${queryParams.nextPage}`
      ).then((response) => response.json()).then((body) => {
          if (!body || !body.length) {
            queryParams.pagesToFetch = 0;
            return queryParams.prevStargazers;
          }
          const fechedStargazers = body.map(({id, login}) => ({id, login}));
          return queryParams.prevStargazers.concat(fechedStargazers);
        });
    }
allStargazers ( queryParams ) { let githubApi = ` ` ; if ( __CLIENT__ ) { const { hostname , port } = window . location ; githubApi = ` ${ hostname } ${ port } ` ; } return fetch ( githubApi + "/repos/RickWong/react-isomorphic-starterkit/stargazers" + ` ${ queryParams . nextPage } ` ) . then ( ( response ) => response . json ( ) ) . then ( ( body ) => { if ( ! body || ! body . length ) { queryParams . pagesToFetch = 0 ; return queryParams . prevStargazers ; } const fechedStargazers = body . map ( ( { id , login } ) => ( { id , login } ) ) ; return queryParams . prevStargazers . concat ( fechedStargazers ) ; } ) ; }
Return a Promise of the previous stargazers + the newly fetched stargazers.
Return a Promise of the previous stargazers + the newly fetched stargazers .
/**
       * On the server, connect to GitHub directly.
       */ //let githubApi = "https://api.github.com"; /**
       * On the client, connect to GitHub via the Hapi proxy route.
       */ /**
       * Load a few stargazers using the Fetch API.
       */ /**
           * Stop fetching if the response body is empty.
           */ /**
           * Pick id and username from fetched stargazers.
           */