1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/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

30 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>
}
}