RPC: temporarily disable argument guards, add cookie support for SSR

(now with full isomorphism... almost!)
This commit is contained in:
41666 2019-03-10 15:24:05 -05:00
parent f30ca78e40
commit c32ee37ca5
5 changed files with 47 additions and 10 deletions

View file

@ -1,14 +1,16 @@
import * as React from 'react'
import RPC from '../config/rpc'
import RPC, { withCookies } from '../config/rpc'
export default class TestRPC extends React.Component {
static async getInitialProps (ctx) {
const user = await withCookies(ctx).getCurrentUser()
console.log(user)
return {
// hello: await RPC.hello('world')
user
}
}
componentDidMount () {
async componentDidMount () {
window.$RPC = RPC
}
@ -19,6 +21,11 @@ export default class TestRPC extends React.Component {
}
render () {
return <div>hello, { this.props.hello }</div>
if (this.props.user == null) {
return <div>hello stranger OwO</div>
}
const { username, avatar, discriminator } = this.props.user
return <div>hello, {username}#{discriminator} <img src={avatar} width={50} height={50} /></div>
}
}