IsomorphicʹσʔλΛऔಘ͢Δྫ
import React from ‘react'
import 'isomorphic-fetch'
export default class extends React.Component {
static async getInitialProps () {
// CORS͕༗ޮͳAPIʹαʔόɺΫϥΠΞϯτํ͔ΒΞΫηε
const res = await fetch(‘http://api.example.com/user/123’)
const user = await res.json()
return { user }
}
render () {
return
hi, {this.props.user.name}!
}
}