أماني مفيد

أماني مفيد

  • NA
  • 142
  • 15.8k

Node js fetch response

Apr 1 2021 9:43 AM
I have this Function , Node js
  1. function get_type(msg){  
  2. try {  
  3. const tok = "xxxxxxx" ;  
  4. const uri = 'https://api.wit.ai/message?v=20200513&q=' + msg;  
  5. const auth = 'Bearer ' + tok;  
  6. fetch(uri, {headers: {Authorization: auth}})  
  7. .then(res => res.json())  
  8. .then(res => console.log(res ))  
  9. catch (error){  
  10. }  
  11.   
  12. }  
  13. });  
I need return Fetch response inside a variable to use it on other function
 
how i can do that

Answers (2)