
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis is a common React issue, not specifically a Sanity problem, but I can help! The issue is that setSessions is a state setter function, not an async function - it doesn't return a promise, so you shouldn't await it.
Here's the corrected code:
useEffect(() => {
const getSessions = async () => {
const data = await fetch("https://api.call")
const json = await data.json()
setSessions(json.collection) // Remove the await here!
}
getSessions().catch(console.error);
}, [])Why this happens:
setSessions is a synchronous function that schedules a state updateawait doesn't make sense hereAdditional improvements for your code:
{sessions.map((s) => (
<option key={s.id || s.name} value={s.name}>
{s.name}
</option>
))}const [sessions, setSessions] = useState([])
const [loading, setLoading] = useState(true)
useEffect(() => {
const getSessions = async () => {
try {
const data = await fetch("https://api.call")
const json = await data.json()
setSessions(json.collection)
} catch (error) {
console.error(error)
} finally {
setLoading(false)
}
}
getSessions()
}, [])useLiveQuery instead of raw fetch calls for better integration with the Studio.The main fix is removing await from setSessions - that should get your component working!
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store