Skip to content

Instantly share code, notes, and snippets.

@bensquire
Last active April 28, 2022 12:14
Show Gist options
  • Save bensquire/716c636984172c942d25dea330952bd5 to your computer and use it in GitHub Desktop.
Save bensquire/716c636984172c942d25dea330952bd5 to your computer and use it in GitHub Desktop.
Trello API Card Attachment using formdata-node and node-fetch (NodeJS)
import fetch from "node-fetch"
import {FormData} from "formdata-node"
import {fileFromPath} from "formdata-node/file-from-path"
const file = './354.jpg'
const cardId = 'REPLACE'
const key = 'REPLACE'
const token = 'REPLACE'
const form = new FormData()
form.set('file', await fileFromPath(file))
form.set('key', key)
form.set('token', token)
await fetch(`https://api.trello.com/1/cards/${cardId}/attachments`, {
method: 'POST',
body: form
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment