I used it in other file where it works properly but this is the following error for a different file: Uncaught Error: marked(): input parameter is undefined or null
import React from 'react';
import axios from "axios";
import { marked } from 'marked';
import { Grid, Typography, Box } from '@material-ui/core'
export default class GetBlogs extends React.Component {
constructor(props) {
super(props);
this.state = {
blog_json: [],
};
}
componentDidMount() {
axios.get(`/api/blog/${this.props.match.params.slug}/?format=json`)
.then((result) => {
this.setState({ blog_json: result.data })
})
.catch(error => {
console.log(error)
})
};
render() {
const blog = this.state.blog_json;
return (
<Grid container justifyContent="center" alignItems="center">
<Grid xs={12} sm={6} lg={6}>
<Box>
<Typography variant="h1" component="div" gutterBottom>{ blog.title }</Typography>
<Typography dangerouslySetInnerHTML={{__html: marked(blog.markdown)}}></Typography>
<Typography>{ blog.author }</Typography>
<Typography>{ blog.date } { blog.time }</Typography>
</Box>
</Grid>
</Grid>
)
};
}