Created
February 10, 2021 10:28
-
-
Save herzzanu/e93779283be451195de00d11fce34ba9 to your computer and use it in GitHub Desktop.
Read file method
This file contains hidden or 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
// mirage/config.js - Adding a method for reading the file | |
function readFile(file) { | |
let reader = new FileReader(); | |
return new Promise((resolve, reject) => { | |
reader.onerror = () => { | |
reject(new Error('There was an error reading the file!')); | |
}; | |
reader.onload = () => resolve(reader.result); | |
reader.readAsText(file); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment