简体   繁体   中英

Get raw data when importing a package dynamically

So while working on a react project i have a requirement of getting the dynamically imported package data in raw format ( text/plain ) instead of default:javascript format

For example:

await import(package_name).then(module => {do_something(module.default)})

but i dont want this to be converted in js but the raw data that is recieved from server of requested package, Anyone can share ideas/solution on this problem, can be aa huge help

Thanks.

You could just use fetch() instead of import() which will return the raw data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM