Monday Quickstart Guide Code not working for Board Query

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;

Hello @fredo!

Can you please send us an email to appsupport@monday.com so that we can take a closer look?

Can you please include your code and what do you see in the console when using console.log(res.data) after the this.setState({context: res.data})?

1 Like

@Matias.Monday , Thanks for your response. There was a typo error from my own end. Everything is working fine now. Thanks

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.