Skip to content

Instantly share code, notes, and snippets.

@ohac
Created Dec 20, 2020
Embed
What would you like to do?
React component for Monacard API
import React from "react"
class Monacard extends React.Component {
constructor(props) {
super(props)
this.state = {
url: null
}
}
componentDidMount() {
const name = this.props.name
fetch('https://card.mona.jp/api/card_detail?assets=' + name)
.then(res => res.json())
.then(
(result) => {
const url = result.details[0].imgur_url
this.setState({url: url})
},
(error) => {
// TODO
})
}
render() {
return (
<img src={this.state.url} alt='' width='224' height='320' />
)
}
}
export default Monacard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment