rsnext/test/integration/lambdas/pages/fetch.js
Tim Neutkens d11a3aa34e
Add tests for isomorphic-unfetch bundling issue (#5805)
* Add tests for isomorphic-unfetch bundling issue

* Remove unneeded extra option

* Remove isomorphic-fetch
2018-12-04 10:59:12 +01:00

29 lines
668 B
JavaScript

import fetch from 'isomorphic-unfetch'
import React from 'react'
export default class extends React.Component {
static async getInitialProps () {
try {
const res = await fetch('')
const text = await res.text()
console.log(text)
return {text}
} catch (err) {
if (err.message.includes('is not a function')) {
return {failed: true, error: err.toString()}
}
return {error: err.toString()}
}
}
render () {
const {failed, error, text} = this.props
return <div className='fetch-page'>
{failed ? 'failed' : ''}
{error}
<div id='text'>
{text}
</div>
</div>
}
}