Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

inbox.nextFile is not a function

ANSWERED

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

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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}`);
  }
}

View best answer in original post

Best Answer
1 REPLY 1

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}`);
  }
}
Best Answer