0
votes

I am using react, webpack and babel. I can't get the id parameter from URL.

I get this error:

-GET http://localhost:8080/edit/bundle.js 404 (Not Found)

-Refused to execute script from 'http://localhost:8080/edit/bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

My code

<Route path="/edit/:id" component={EditExpensePage} />

My URL

http://localhost:8080/edit/35

Thanks for reading and please help me.

2

2 Answers

0
votes

It looks like you might be using a relative path to load bundle.js.

Check the script tag in your HTML. If it looks like this:

<script src="bundle.js"></script>

then try adding a slash before the file name:

<script src="/bundle.js"></script>
0
votes

It's actually not the problem with react router

The problem is in your html file

I am not sure whether you do it intentionally or not, but bundle.js usually located in root path, e.g. http://localhost:8080/bundle.js

Check whether your reference is wrong.