Ok, super easy one here, but as a newbie to async / await this did catch me out.
Let’s pretend we have a function:
export function login(username, password) { const requestConfig = { method: 'POST', mode: 'cors', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username, password }) }; const loginResponse = await fetch('https://your.api/login', requestConfig);
This will present an error in WebStorm, and Googling came up only with a bug report from 2015.
In my case, WebStorm would give two different error messages:
or
Ready to kick yourself?
export async function login(username, password) { const requestConfig = { method: 'POST', mode: 'cors', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username, password }) }; const loginResponse = await fetch('https://your.api/login', requestConfig);
This I tell you brother, you can’t have one without the other 🙂
Thank you 😀 :D.