Skip to main content

Simple authentication and query example in javascript?

  • February 22, 2020
  • 3 replies
  • 5029 views

sbaden

Where can I find a simple authentication and query example for javascript? I can’t seem to find an example anywhere.

Something as simple as returning all of your boards…

This topic has been closed for replies.

3 replies

  • New Participant
  • March 18, 2020

Does this help?

I made a basic Node.js repo:

GitHub

sbaden
  • Author
  • New Participant
  • March 19, 2020

Yes, thank you Ash for the response!

This is what I ended up with:

import { GraphQLClient } from 'graphql-request';

let getBoards = () => {
    const client = new GraphQLClient(profile.monday_url, {
      headers: {
        Authorization: profile.monday_access_token,
      },
    })

    const query = `{
        boards() {
            id
            name
            owner {
                id
                name
            }
        }
    }`

    client.request(query)
      .then(data => {
        setBoards(data.boards.map(board => {
            return {
                id: board.id,
                name: board.name
            }
        }));
      })
  }
}

dipro
Forum|alt.badge.img
  • Leader
  • July 16, 2020

We now have an API tutorial for Javascript. Check it out here: API Javascript Quickstart