0

I am trying to use axios in my js file but when i try to require it using

const axios = require('axios");

it shows error 'require is not defined' if i try importing axios using

import axios from 'axios'

it shows error 'cannot use import statement outside a module' if i add type='module' in script tag it shows error: Access to script at 'file:///home/shubham-sharma/code/test.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted. test.html:7
GET file:///home/shubham-sharma/code/test.js net::ERR_FAILED

axios files have already set type to module in package.json

PS: i have installed axios globally but i also tried by installing it in the directory still got the error

the methods given in associated question i've tried all of them and my issue isn't resolved. this is a different question

shubh
  • 1
  • 3

0 Answers0