Skip to content

Instantly share code, notes, and snippets.

@andeplane
Created January 31, 2018 20:51
Show Gist options
  • Save andeplane/cd9b67048a1648dba0b06e9966b6c60f to your computer and use it in GitHub Desktop.
Save andeplane/cd9b67048a1648dba0b06e9966b6c60f to your computer and use it in GitHub Desktop.
import test from './test.txt'
class A {
constructor() { }
async loadFile(filename) {
let data = await (await fetch(filename))
return data
}
}
class B extends A {
constructor() {
super()
this.contents = ''
}
async loadFile(filename) {
let data = await super.loadFile(filename)
data.text().then( text => {
console.log('Text: ', text)
this.parse(text)
}).catch( error => {
console.log('Error: ', error)
})
}
parse (data) {
this.contents = data
console.log('Parsing data: ', data)
}
}
let b = new B()
b.loadFile(test).then( () => {
console.log('Got data now: ', b.contents)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment