Advertisement
thongvsgame

fetch

Jul 12th, 2022
1,304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // https://deno.land/
  2. // fetch_deno.js
  3. let url = 'https://www.premint.xyz/'
  4. fetch(url).then(async res => {
  5.     console.log(await res.text())
  6.     console.log('\x1b[32m', 'deno fetch status (then)', '\x1b[0m', res.status)
  7. }).catch(async err => {
  8.     console.log(err)
  9.     console.log('\x1b[31m', 'deno fetch status (catch)', '\x1b[0m', err.status)
  10. })
  11.  
  12.  
  13. // https://nodejs.org/
  14. // fetch_node.js
  15. const axios = require('axios')
  16.  
  17. let url = 'https://www.premint.xyz/'
  18.  
  19. axios.get(url).then(res => {
  20.     console.log(res.data)
  21.     console.log('\x1b[32m', 'node axios status (then)', '\x1b[0m', res.status)
  22. }).catch(err => {
  23.     console.log(err.response.data)
  24.     console.log('\x1b[31m', 'node axios status (catch)', '\x1b[0m', err.response.status)
  25. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement