Hi, I’m using Preact’s useState
and useEffect
to update a ‘Local Events’ component on this webpage using a Fauna UDF and a secret with narrowly-defined privileges. This works in Firefox on my Linux laptop, in Firefox and Safari on my MacOS laptop and in Firefox and Safari on my iPad, but fails on my iPhone in both Firefox and Safari with the message:
Unhandled Promise Rejection: Syntax Error: Unexpected Token '?'
In devtools on my laptop, I see a 200 status for a POST to db.us.fauna.com, and the correct JSON data logged by the line console.log('ret.data', ret.data)
, but on the iPhone only the error gets logged, and it shows 304 for a GET request.
import { useState, useEffect } from 'preact/hooks';
import { Fragment } from 'preact';
import faunadb from 'faunadb'
export default function LocalEvents() {
const [eventArr, setEventArr] = useState([])
useEffect(() => {
const fetchData = async () => {
const q = faunadb.query;
const client = new faunadb.Client({
secret: FAUNA_SECRET,
domain: 'db.us.fauna.com',
});
await client.query(
q.Call('future_events')
)
.then((ret) => {
console.log('ret.data', ret.data)
setEventArr(ret.data)
})
.catch(console.error);
}
fetchData()
.catch(console.error);
}, []);
return (
<Fragment>
<h2>Upcoming Events in the Portland Metro Area</h2>
... populate the local events section with some links ...
</Fragment>
)
Thanks for any help on this!
Edit: I should have mentioned, this is an iPhone 6, software version 12.5.5. Also, just tested on Android and the error did not occur.