I am experiencing some unexpected behavior using react and fetch. It should be very straight forward.
My code looks like the following:
import React, { Component } from 'react';
class App extends Component {
componentDidMount() {
fetch('/dict.json')
.then(res => res.json())
.then(json => console.log(json))
}
render() {
return (
<p>Example</p>
);
}
}
and my folder structure looks like this
- src
|_app.js
|_dict.json
- index.html
When I check the network it is requesting the index.html page which makes no sense to me. Has anyone experienced this before?