0

i use node as a API gateway and given a sample code below.I want to know any performance issues that may be caused on my code due to async-await .If so what are the best options ?.

 router.post("/index", async (req, res) => { return res.json( await CommenCall('post', url, req.body)) }) const CommenCall = async (method='get', url,body) => { try { data= await axios.post(url, body) if (data.data != null) { return data.data } else { return err } } catch(err) { console.log(err) return err } } 

2
  • This is invalid syntax: async await axios.post(url, body). As for performance, it shouldn't be different than regular promises. Commented May 8, 2020 at 8:23
  • not yet,i have updated the code Commented May 9, 2020 at 8:54

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.