This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
// api.js
const
axios
=
require
(
'axios'
)
;
const
fetchData
=
async
(
url
)
=>
{
try
{
const
response
=
await
axios
.
get
(
url
)
;
return
response
.
data
;
}
catch
(
error
)
{
throw
error
;
}
}
;
module
.
exports
=
fetchData
;
view raw
basic-api-call.js
hosted with ❤ by
GitHub