Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch problem on iOS 17 simulator #64

Open
petrot opened this issue Nov 14, 2023 · 1 comment
Open

Fetch problem on iOS 17 simulator #64

petrot opened this issue Nov 14, 2023 · 1 comment

Comments

@petrot
Copy link

petrot commented Nov 14, 2023

I got the following error on iOS simulator:

CapacitorBackgroundRunner/BackgroundRunner.swift:160: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

The problematic code is this:

returnObj.toDictionary().forEach { key, value in. // Line 160
   dict[String(describing: key)] = value
}

My code in the runner.js file:

addEventListener("fetchTest", async (resolve, reject, args) => {
  try {
    const res = await fetch("https://randomuser.me/api/");
    console.log("res???", res);

    resolve('plain text');
  } catch (err) {
    console.error(err);
    reject(err);
  }
});
@jethro91
Copy link

Hi @petrot , I found the same issue. The quick solution is to put the resolve() value as an object.

addEventListener("fetchTest", async (resolve, reject, args) => {
  try {
    const res = await fetch("https://randomuser.me/api/");
    console.log("res???", res);

    resolve({
     text: 'plain text'
     });
  } catch (err) {
    console.error(err);
    reject(err);
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants