Skip to content

Commit

Permalink
Remove axios in favour of native fetch api (#261)
Browse files Browse the repository at this point in the history
* Remove axios in favour of native fetch api

* Format axios -> fetch change
  • Loading branch information
dispherical authored May 26, 2024
1 parent 8489039 commit 1677fc9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"dependencies": {
"@prisma/client": "^5.14.0",
"@slack/bolt": "^3.18.0",
"axios": "1.7.2",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"form-data": "^4.0.0",
Expand Down
19 changes: 7 additions & 12 deletions setup/cave-channel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const axios = require('axios')
const { transcript } = require('../util/transcript')
const { client } = require('../app')

Expand All @@ -9,14 +8,12 @@ async function setupCaveChannel() {
}

async function postImage() {
const file = await axios({
method: 'get',
url: transcript('files.cave-image'),
responseType: 'stream',
})
const file = Buffer.from(
await (await fetch(transcript('files.cave-image'))).arrayBuffer()
)
const response = await client.files.uploadV2({
channels: transcript('channels.cave'),
file: file.data,
file: file,
filename: 'you fall into a cave...',
})
}
Expand All @@ -37,11 +34,9 @@ async function postMessage() {
}

async function postAudio() {
const file = await axios({
method: 'get',
url: transcript('files.cave-audio'),
responseType: 'stream',
})
const file = Buffer.from(
await (await fetch(transcript('files.cave-audio'))).arrayBuffer()
)
console.log({
channel: transcript('channels.cave'),
})
Expand Down
9 changes: 0 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,6 @@ available-typed-arrays@^1.0.7:
dependencies:
possible-typed-array-names "^1.0.0"

[email protected]:
version "1.7.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.2.tgz#b625db8a7051fbea61c35a3cbb3a1daa7b9c7621"
integrity sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==
dependencies:
follow-redirects "^1.15.6"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

axios@^1.6.0, axios@^1.6.5:
version "1.7.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.1.tgz#522145622a09dfaf49359837db9649ff245a35b9"
Expand Down

0 comments on commit 1677fc9

Please sign in to comment.