This package has been deprecated

Author message:

This is old and Coffeescript. Use trello-web instead.

trello-browser

0.0.6 • Public • Published

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-browser
Trello = require 'trello-browser'
trello = new Trello TRELLO_API_KEY
 
# doing auth 
Promise.resolve().then(->
  # perhaps you have some token stored at localStorage 
  return localStorage.getItem('token')
).then((existingToken) ->
  if existingToken
    # no need to call auth 
    trello.setToken(existingToken)
    return
 
  trello.auth({
    name: 'My Trello App'
    scope:
      read: true
      write: true
      account: true
    expiration: '1hour'
  })
  # this will open a friendly Trello popup 
).then(->
  # trello.token will contain the token you got from the user 
  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.')
)

Besides these calls, you can do .get, .put, .post and .del, for example:

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

When uploading attachments to /1/cards/:id/attachments, you can pass a File object or a string to be turned into a file:

file = 'eat tomatoes.'
// or file = fileInput.files[0]
 
trello.post('/1/cards/32478324/attachments'{
  name: 'tomato.txt',
  mimeType: 'text/plain',
  file: file
}).then(console.log.bind console)

Package Sidebar

Install

npm i trello-browser

Weekly Downloads

1

Version

0.0.6

License

MIT

Last publish

Collaborators

  • fiatjaf