I have a function getData
in functions.js
, when I called in another file, scripts.js
it returns promise not an object.
//------ functions.js ------
export async function getData(arg1,arg2,arg3) {
...
let result = await fetch(proxyUrl + targetUrl, requestOptions)
.then(response => response.json())
.catch(error => console.log('error', error));
return result
}
When I call like this I get a Promise:
//------ scripts.js ------
import {getData} from './functions';
let result = getData(arg1,arg2,arg3)
console.log(result)
But even I called like this, I get an Error:
//------ scripts.js ------
import {getData} from './functions';
let result = awiat getData(arg1,arg2,arg3)
console.log(result)
"Uncaught SyntaxError: Unexpected reserved word"