Reputation: 11
Line 20:19: Parsing error: Can not use keyword 'await' outside an async function
18 |
19 | try{
20 | const res = await axios.post('/upload', formData, {
| ^
21 | headers:{
22 | 'Content-Type':'multipart/form-data'
23 | }
Upvotes: 1
Views: 1494
Reputation: 49
You can't use directly await like this. You should create a function with async and then you can use await in function like that;
const myFunction = async () => {
try {
const res = await axios.get('bla')
}
}
Upvotes: 3