Advertisement
A_God

API fetch

Mar 29th, 2022
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var requestOptions = {
  2.     method: 'GET',
  3.     redirect: 'follow'
  4. };
  5.  
  6. function apiCall() {
  7.  
  8.  
  9. fetch("https://api.adviceslip.com/advice", requestOptions)
  10.   .then(response => response.text())
  11.   .then(result => console.log(result))
  12.   .catch(error => console.log('error', error));
  13. }
  14. apiCall();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement