I’m new to React and TS so maybe I’m just an idiot but so far I’ve been doing fine building out my app but I need to use the file-transfer plugin and this is where everything breaks down.
constructor(private transfer: FileTransfer, private file: File) { } doesn’t work under the imports and only works if I put it in a class, however then “FileTransfer” is viewed as a value and not a type. However if it’s outside of the class then it gets the error cannot find name constructor.
Then fileTransfer.download() gets me Duplicate identifier ‘fileTransfer’.ts(2300)
I could share with you the code that I have but honestly it’s just a patch-work piece of garbage that has nothing working so instead I’ll show you what I wanted to work
constructor(private transfer: Transfer, private file: File) { }
const fileTransfer: TransferObject = this.transfer.create();
function getLatestTealist() {
const url = 'http://dandtea.com/tealist.json';
fileTransfer.download(url, this.file.dataDirectory + 'current_compressed.json').then((entry) => {
console.log('download complete: ' + entry.toURL());
// MAKE TOAST SAYING "LATEST VERSION GRABBED"
}, (error) => {
// handle error
alert(error);
});
And maybe someone can help me understand how to make that work. I really appreciate it.
2 posts - 2 participants