I\'m trying to migrate the code from angular to react. Not sure if it\'s correct, just need some help if I\'m going in the right direction or not. I don\'t know angular so I\'m
Try this, Hope it will work.
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
textdata: [],
textlen: 0
};
}
textanalysis(){
fetch('/api/analyse', {
method: 'POST',
body: JSON.stringify({
snippetdesc: 'snippetDescription'
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
.then(response => response.json())
.then((textdata) => {
this.setState({
textdata : textdata.data,
textlen : snippetDescription.split(' ').length
});
},(error) => {
console.log(error)
})
}
}