Last active
April 28, 2022 12:14
-
-
Save bensquire/716c636984172c942d25dea330952bd5 to your computer and use it in GitHub Desktop.
Trello API Card Attachment using formdata-node and node-fetch (NodeJS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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