Created
July 25, 2016 20:17
-
-
Save ricardokdz/baa89ed366badfab0fe37ed35ab16095 to your computer and use it in GitHub Desktop.
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 { 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