Last active
January 8, 2021 08:33
-
-
Save miteshmap/17d32c00eb91ebd4fbd54af3fdc96a14 to your computer and use it in GitHub Desktop.
Download blob data with axios
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 axios from "axios"; | |
import { saveAs } from "file-saver"; | |
axios(`${apiUrlPrefix}/file/5`, { | |
method: 'GET', | |
responseType: 'blob', | |
headers: { | |
'Authorization': `Bearer ${token}`, | |
} | |
}).then(response => { | |
saveAs(new Blob([response.data], {type: "text/plain;charset=utf-8"}), 'file.txt'); | |
}) | |
.catch(error => { | |
console.log(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment