async function submitForm(e){
e.preventDefault()
console.log(e.target)
try {
const response = await axios.post('/api/<PATH>', {username, password});
console.log(response.data);
const token = response.data.token
if (token) {
const json = jwt.decode(token) as { [key: string]: string};
const secondResponse = await axios.post('/api/<PATH>', { token });
const data = secondResponse.data;
An error is occurring on this particular line of code:
await axios.post('/api/<PATH>', { token })
My IDE is displaying the following message:
TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules.
The current code cannot be compiled due to this issue. I am attempting to pass the token value into another axios API call, but it seems impossible because of the aforementioned error. Any suggestions on how to resolve this would be greatly appreciated.