I'm using react and working on getting json files in the component.
I want to get the input.json file using fetch, but it's not data in the console. Why is this and how do I get the data?
input.json
{
"formId": 1,
"title": "from",
"items": [{
"itemId": 1,
"title": "style",
"formType": 1,
"options": [{
"id": 1,
"text": "one"
}, {
"id": 2,
"text": "two"
}, {
"id": 3,
"text": "three"
}]
}
App.js
import React from 'react';
import './App.css';
import inputData from './assets/input.json';
function App() {
const getData = () => {
fetch(inputData).then(response => {
return response;
}).then(data => {
console.log(data);
}).catch(err => {
console.log(err)
});
}
getData();
return (
<div className="App">
<h2>Fetch</h2>
</div>
);
}
export default App;