#7 done (c'est moche mais TG)
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
32
pages/coins.jsx
Normal file
32
pages/coins.jsx
Normal file
@ -0,0 +1,32 @@
|
||||
import React from 'react'
|
||||
import CoinItem from '../components/CoinItem'
|
||||
import fetch from 'isomorphic-unfetch'
|
||||
|
||||
export default class Flux extends React.Component {
|
||||
|
||||
static async getInitialProps(ctx) {
|
||||
const coindId = ctx.query.location
|
||||
const pseudo = ctx.query.pseudo
|
||||
let hostname = ''
|
||||
if (ctx.req) {
|
||||
hostname = `http://${ctx.req.headers.host}`
|
||||
|
||||
}
|
||||
const data = await (await fetch(`${hostname}/api/photos`)).json()
|
||||
const locations = await (await fetch(`${hostname}/api/coins`)).json()
|
||||
return {data, locations}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
{this.props.locations.map((el, index) => {
|
||||
// console.log(el, this.props.data.filter((item) => item.coinId == el.id))
|
||||
return (
|
||||
<CoinItem key={index} item={el} photos={this.props.data.filter((item) => item.coinId == el.id)} />
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user