Am new to Monday API and am working with Monday quick Start developers sample code here.
Docs link
I have followed all the instructions, enable board read permission. When I run the code as suggested, my board is empty. it displays { “boards”: [] }
What am I doing wrong in the code below. Thanks
import React from "react";
import "./App.css";
import mondaySdk from "monday-sdk-js";
import "monday-ui-react-core/dist/main.css"
//Explore more Monday React Components here: https://style.monday.com/
import AttentionBox from "monday-ui-react-core/dist/AttentionBox.js"
const monday = mondaySdk();
class App extends React.Component {
constructor(props) {
super(props);
// Default state
this.state = {
settings: {},
name: "",
};
}
componentDidMount() {
// TODO: set up event listeners
monday.listen("context", res => {
this.setState({context: res.data});
console.log(res.data);
monday.api(`query ($boardIds: [Int]) { boards (ids:$boardIds) { name items(limit:1) { name column_values { title text } } } }`,
{ variables: {boardIds: this.state.context.boardIds} }
)
.then(res => {
this.setState({boardData: res.data});
});
})
}
render() {
return <div className="App">
<AttentionBox
title="Hello Monday Apps vv!"
text="Let's start building your amazing app, which will change the world!"
type="success"
/>
{JSON.stringify(this.state.boardData, null, 2)}
</div>;
}
}
export default App;