Add two headers Content-Type
and Accept
to be equal to application/json
.
handleGetJson(){ console.log("inside handleGetJson"); fetch(`./fr.json`, { headers : { 'Content-Type': 'application/json', 'Accept': 'application/json' } }) .then((response) => response.json()) .then((messages) => {console.log("messages");}); }
Related Posts:
- “SyntaxError: Unexpected token < in JSON at position 0"
- jQuery AJAX cross domain
- Uncaught TypeError: Cannot read property ‘props’ of null
- JSON.parse() not working
- react router v^4.0.0 Uncaught TypeError: Cannot read property ‘location’ of undefined
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- How to allow CORS in react.js?
- “NS_ERROR_DOM_BAD_URI: Access to restricted URI denied”
- “SyntaxError: Unexpected token < in JSON at position 0"
- Invariant Violation: Objects are not valid as a React child
- SyntaxError: Unexpected token o in JSON at position 1
- syntax error: unexpected token <
- SyntaxError: Unexpected token o in JSON at position 1
- What is JSONP, and why was it created?
- React.js: Set innerHTML vs dangerouslySetInnerHTML
- React – uncaught TypeError: Cannot read property ‘setState’ of undefined
- Understanding unique keys for array children in React.js
- Difference between npx and npm?
- Array of JSON Objects
- Chrome sendrequest error: TypeError: Converting circular structure to JSON
- Fetch: POST JSON data
- Reactjs – Form input validation
- TypeScript React.FC
confusion - How to read an external local JSON file in JavaScript?
- SyntaxError: Unexpected token o in JSON at position 1
- Loop inside React JSX
- Can’t resolve module (not found) in React.js
- How to read an external local JSON file in JavaScript?
- How to implement navbar using react
- Loop inside React JSX
- React this.setState is not a function
- Console logging for react?
- What is the “right” JSON date format?
- In reactJS, how to copy text to clipboard?
- SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag
- What is the “right” JSON date format?
- Infinite Scrolling in Asp.Net MVC with jQuery / AJAX Issues
- Setting a backgroundImage With React Inline Styles
- Failed to load resource: net::ERR_FILE_NOT_FOUND loading json.js
- How to pass props to {this.props.children}
- React eslint error missing in props validation
- What does on() in JavaScript do?
- How to import image (.svg, .png ) in a React Component
- Adding images to a Bootstrap Carousel with AJAX
- How to refresh a Page using react-route Link
- Loading local JSON file
- node.js TypeError: path must be absolute or specify root to res.sendFile [failed to parse JSON]
- Console is throwing Unterminated JSX contents error
- How to scroll to an element?
- How to convert selected HTML to Json?
- Failed to compile. Module not found: Can’t resolve ‘react-router-dom’
- How to add multiple classes to a ReactJS Component?
- Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which is inside StrictMode
- push object into array
- module.exports “Module is not defined”
- how to download file in react js
- Trying to use fetch and pass in mode: no-cors
- React’s setState method with prevState argument
- onEnter not called in React-Router
- Uncaught TypeError: Cannot read property ‘call’ of undefined at __webpack_require__
- Async/await in componentDidMount to load in correct order
- Why use Redux over Facebook Flux?
- Local package.json exists, but node_modules missing
- Access Control Origin Header error using Axios
- Refused to execute script, strict MIME type checking is enabled?
- jQuery Ajax POST example with PHP
- TypeError: res.json is not a function
- Can’t perform a React state update on an unmounted component
- onClick not working React js
- This.props.dispatch not a function – React-Redux
- How to add a keyboard listener to my onClick handler?
- How to add a keyboard listener to my onClick handler?
- React router not showing browser history
- JSON.parse unexpected token s
- Jest encountered an unexpected token
- How to filter JSON Data in JavaScript or jQuery?
- Uncaught ReferenceError: React is not defined
- What do these three dots in React do?
- Expected ‘this’ to be used by class method
- Uncaught SyntaxError: Unexpected token with JSON.parse
- How do I handle newlines in JSON?
- Update style of a component onScroll in React.js
- Ajax success function
- Correct modification of state arrays in React.js
- JSX not allowed in files with extension ‘ .js’ with eslint-config-airbnb
- JAX post error : Refused to set unsafe header “Connection”
- “React.Children.only expected to receive a single React element child” error when putting
and in a - $http.get(…).success is not a function
- Await is a reserved word error inside async function
- Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (
) - Implementing Isomorphic JavaScript (React JS) in WordPress?
- How to use wp_localize_script in custom page template?
- Changing the entire control choices using wp.customize with JavaScript
- Adding wp_ajax to a theme outside functions.php (on specific template page)
- Dynamically insert values in a WordPress SelectControl Options field
- var is undefined in a Gutenberg block
- Creating a Multi-Level Associative Object Using AJAX
- AngularJS with route and JSON API
- How do I query posts by a sub value with the API?
- Gutenberg core/file add style support in js/ json