Hello Cockpit Community ;
Any one to help me why am getting this error when i try to read my collections from cockpit.
Here is an error that am getting in the browser when i run the app.
Unhandled Rejection (SyntaxError): Unexpected token < in JSON at position 0
Here is my react component where am reading my collection as JSON
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
constructor() {
super();
this.state={items:[]};
}
componentDidMount(){
fetch('/api/collections/get/posts?token=6d6126a5613634a710aee0ddbadbe1')
.then(res => res.json())
.then(res => console.log(res));
}
render() {
return(
<div>
{this.state.items.length ?
this.state.items.map(item=><div key={item.id}>{item.body}</div>)
: <li>Loading...</li>
}
</div>
)
}
}
export default App;