Advertisement
PadmaJS

Untitled

Aug 10th, 2021
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. const url = 'https://random-data-api.com/api/stripe/random_stripe'
  2. const getData = async () => {
  3. let info = new Promise((resolve,reject) => {
  4. return fetch(url).then(response => {
  5. response.json()
  6. }).then(json => {
  7. resolve()
  8. return json
  9. }).catch(err => {
  10. console.log(err);
  11. })
  12. })
  13. info.then((data)=> {return {data}})
  14. }
  15. console.log(getData());
  16. fetch(url).then(response => {
  17. response.json()
  18. }).then(json => {
  19. console.log(json);
  20. }).catch(err => {
  21. console.log(err);
  22. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement