Click to Download .ICS File

Viewed 177

In my React project, I have a calendar .ics file in my local folders and want the user to download once they click a button so I'm providing the path to the .ics file in that button. However, I'm getting this error:

"Module parse failed: Unexpected token (4:6) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file."

How do I simply have users click a button to download an .ics file?

1 Answers

Introduction

I was going to just add a comment to your answer, since I don't have a definitive answer for your question, but it turns out that I need a minimum of 50 reputation, so...

I'm not sure if provided enough information for your problem, but I'll answer based on what could understand from your statements.

The Problem

[...] However, I'm getting this error:

"Module parse failed: Unexpected token (4:6) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file."

I don't know what module bundler your are using, but it seems that your bundler can't recognize .ics files. Hence, you need to declare the type of file. Check your module bundler configuration files and add the required support to the aforesaid extension. If you're using Webpack, for example, change the rules attribute of your webpack.config document adding a new rule, notice that, in this case, you'll need to provide a loader.


I hope this helps. This is my first answer here on StackOverflow, sorry if I misunderstood anything or something simillar.

Related