DEV Community

loading...

Discussion on: HTTP request with ES6 tagged templates

Collapse
vaheqelyan profile image
Vahe Author • Edited

Even so ?

async function getUser(user) {
  const { data } = await get`https://api.github.com/users/${user}`;
}
Collapse
itachiuchiha profile image
Itachi Uchiha

Using:

getUser`vahe`

I don't want to misunderstand. This post so informative. Thanks for this. I just don't like this syntax :D

But this syntax acceptable. Which means, we'll use some libraries that use this syntax.

Thread Thread
vaheqelyan profile image
Vahe Author
async function getUser(user) {
  const { data } = await get`https://api.github.com/users/${user}`;
  return data;
}
getUser("google").then(res => {
  console.log(res);
});