Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricardokdz/baa89ed366badfab0fe37ed35ab16095 to your computer and use it in GitHub Desktop.
Save ricardokdz/baa89ed366badfab0fe37ed35ab16095 to your computer and use it in GitHub Desktop.
import { get } from '../../state'
import { POST } from '../../http'
import { apiUrlNew } from '../../garupa'
const setAvatar = (file) => new Promise((resolve, reject) => {
const reader = new FileReader()
reader.onload = function (e) {
POST(`${apiUrlNew}/users/avatar`, {
body: {
token: get('session.token'),
avatar: this.result
}
})
.then(() => resolve(console.log('Upload ok')))
.then((err) => reject(err))
}
reader.readAsDataURL(file)
})
export default setAvatar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment