0
const { default: axios } = require("axios");

i have problem with gettin data. how can I fix this?

su-wan Kenobi
  • 223
  • 1
  • 4
  • 10
  • `require` is used in Node but `import` is used in the browser. – phuzi Mar 02 '22 at 12:39
  • https://stackoverflow.com/questions/23603514/javascript-require-function-giving-referenceerror-require-is-not-defined. Possible duplicate if that one, please check the answers on that question. – Andrew Mar 02 '22 at 12:39
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Mar 02 '22 at 12:59

1 Answers1

1

you have to import axios library

import axios from 'axios';
jeremy-denis
  • 6,368
  • 3
  • 18
  • 35
  • when I delete the code I can get the data. but I don't know it's okay – su-wan Kenobi Mar 02 '22 at 12:53
  • In that xase you should have import axios somewhere. if axios.get (for sample) is available so you should have a working project – jeremy-denis Mar 02 '22 at 12:56
  • 1
    Just in case someone else asks, you can also do something like `window.axios = import('axios')`, especially useful for `lodash`, `bootstrap`, and other packages that are imported this way. – Zeke Aug 10 '22 at 20:19