Comments (3)
Yep! That fixed it. Good call @jbsmith731 🎉
I'll close and create a separate issue for the polyfill.
#82
from after.js.
@jforaker I could be wrong but I don't think fetch
will work on the server. I was able to fetch the data on both the client and server using isomorphic-fetch.
import React from 'react';
import { NavLink } from 'react-router-dom';
require('es6-promise').polyfill();
require('isomorphic-fetch');
class About extends React.Component {
static async getInitialProps({ req, res, match }) {
const hn = await fetch('https://node-hnapi.herokuapp.com/news');
const stuff = await hn.json();
return { stuff };
}
render() {
return (
<div>
<NavLink to="/">Home</NavLink>
<NavLink to="/about">About</NavLink>
<h1>About</h1>
<pre>
{this.props.stuff
? this.props.stuff.map(item => <p key={item.id}>{item.title}</p>)
: 'Loading...'}
</pre>
</div>
);
}
}
export default About;
from after.js.
@jbsmith731 want to submit a PR to modify polyfill.js with isomorphic fetch?
from after.js.
Related Issues (20)
- Error on using transitionBehavior="instant" HOT 3
- Make After.js http server agnostic HOT 3
- Grommet integration example HOT 1
- Is After.js not meant to support the latest version of Razzle? HOT 2
- After.js and @loadable/component it works incorrectly? HOT 5
- Cannot find module 'undefined', chunks.json not created in build folder after upgrading razzle to 4.1.0 HOT 2
- `TypeError: reactRouterDom.withRouter is not a function` after using `create-after-app` HOT 4
- Does After.js support something similar to next/head? HOT 2
- problematic set status after redirect HOT 1
- Brotli compression algorithm support on production? HOT 2
- HMR error: process is not defined HOT 3
- redirectTo not working, Throwing Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client HOT 4
- Component not triggering after browser back button HOT 1
- How to use Graphql with apollo-client or any other client in afterJS?
- loadable-component with After.js - any sample repo to get me started?
- How to prevent calling getInitialProps when follow the nested route?
- create-after-app issue with dependencies conflict
- Hash links are re-rendering page
- Status of this project HOT 16
- Potential bug with route matching HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from after.js.