Giter Site home page Giter Site logo

trello-web-1's Introduction

An alternative to Trello's client.js for interfacing with Trello from the browser, using CORS.

All calls return promises (with lie).

Install with

npm install trello-web
const Trello = require('trello-web')
const trello = new Trello(TRELLO_API_KEY)

Promise.resolve().then(() =>
  localStorage.getItem('token')
).then(existingToken => {
  if (existingToken) {
    trello.token = existingToken
  } else {
    return trello.auth({
      name: 'My Trello App',
      scope: {
        read: true,
        write: true,
        account: true
      },
      expiration: '1hour'
    })
  }
}).then(() =>
  trello.get("/1/tokens/" + trello.token + "/member", {
    fields: 'username,id,email'
  })
).catch(e => {
  console.log('something bad happened, or the user took too long to authorize.', e)
})

When you have a token, you can do .get, .put, .post and .del, for example:

trello.get('/1/boards').then(console.log)
trello.del('/1/cards/782346238742').then(() => console.log('deleted card'))
trello.post('/1/cards/21838932983/actions/comments', {text: 'hello'}).then(data => console.log('created comment', data))
trello.put('/1/cards/2342632532532/desc', {value: 'hello world!'}).then(console.log)

trello-web-1's People

Contributors

fiatjaf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.