This repository has been archived on 2023-06-06. You can view files and clone it, but cannot push or open issues or pull requests.
IMIE_CC/pages/flux.jsx
Florian Bouillon e1dd4c94a3
#1 Utilisation des vrai données
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
2020-04-29 14:39:57 +02:00

27 lines
520 B
JavaScript

import React from 'react'
import FluxItem from '../components/FluxItem'
import fetch from 'isomorphic-unfetch'
export default class Flux extends React.Component {
static async getInitialProps(ctx) {
let hostname = ''
if (ctx.req) {
hostname = `http://${ctx.req.headers.host}`
}
const data = await (await fetch(`${hostname}/api/photos`)).json()
return {data}
}
render() {
return (
<div>
{this.props.data.map((el, index) => (
<FluxItem key={index} item={el} />
))}
</div>
)
}
}