12-26-2018 19:02 - edited 12-26-2018 19:08
12-26-2018 19:02 - edited 12-26-2018 19:08
I am getting the following error for using file transfer from device to companion app
[7:00:52 PM]TypeError: o.inbox.nextFile is not a function nextFile at companion/index.js:193,26 a at sim-file:/bootstrap:63,35 t.e.dispatchEvent at sim-file:/bootstrap:76,1 ? at undefined:1,32 EventEmitter.electron.ipcRenderer.on (/Applications/Fitbit OS at Simulator.app/Contents/Resources/electron.asar/renderer/web-frame-init.js:36,30 EventEmitter.emit at events.js:182,13
when I use below
while (fileName = inbox.nextFile()) {
// process each file
console.log("Received:", fileName);
}I have already imported
import { inbox } from "file-transfer";Any idea whats wrong?
Note: This is on companion app using the new API available for SDK 3.0
Answered! Go to the Best Answer.
Best Answer12-26-2018 22:07
12-26-2018 22:07
Answering my own question
On Companion you have to use following
async function processAllFiles() {
let file;
while ((file = await inbox.pop())) {
const payload = await file.text();
console.log(`file contents: ${payload}`);
}
}
12-26-2018 22:07
12-26-2018 22:07
Answering my own question
On Companion you have to use following
async function processAllFiles() {
let file;
while ((file = await inbox.pop())) {
const payload = await file.text();
console.log(`file contents: ${payload}`);
}
}