score:1
Accepted answer
useEffect(() => {
fetch(SERVER_URL + "salesmen/1")
.then((response) => response.json())
.then((data) => {
// fruits: responseData
const fruitdata = data.inventory.map((p) => { // mapping on invenroty will resolve the issue
return {
inventory: p.inventory,
theDate: p.inventory.theDate,
description: p.inventory.descrip,
};
});
console.log(fruitdata)
setfruits(fruitdata);
})
.catch((err) => console.error(err));
}, []);
Source: stackoverflow.com
Related Query
- Javascript JSON API fetch nested json
- How to map nested JSON properties collected with JS fetch API and SWR
- React - Fetch Data from API and map nested JSON
- typeerror: cannot read property of undefined javascript - empty JSON object from fetch despite postman showing object from API
- React.js: loading JSON data with Fetch API and props from object array
- How to upload image using javascript fetch api and express multer
- Fetch request on API Rails doesn't return json
- how to handle values other than json in fetch api call
- Displaying JSON data using Fetch API and map() in Javascript/Reactjs
- How to download single file with multiple chunks in javascript using fetch API
- How to use map function with JSON object fetch though an API
- How to change data in a nested JSON by javascript lodash
- Display/Map Nested JSON fields in React JavaScript
- How to send authorization, cookie headers with javascript fetch API
- JavaScript - fetch api data is run too late
- How to Sort Dates, Numbers, Strings from the array of nested JSON objects in Javascript
- TypeError: Cannot read property 'fixtures' of undefined, Nested Json From Fetch Call
- Why will my fetch API call map one nested objects, but not the other?
- How to fetch json data from a url that requires an api key to access the data in reactjs?
- Not able to access nested objects inside a JSON in Javascript
- How to make a fetch API in Javascript to be modular
- How to iterate JSON nested array in REACT JS API call?
- How to fetch images in json api in react?
- Finding values or objects in a json file with nested objects and passing the result object to child in Javascript and react
- Map JSON from API Javascript
- Use multiple React useState() hooks to fetch Category title and posts from json api
- How to fetch Json nested and Make it Array of object in React
- Extracting data from json object from API with JavaScript React Native
- Fetch API - How to transform JSON into HTML
- Parsing data then mapping from JSON using Fetch API
More Query from same tag
- ReactJS: e.preventDefault() is not a function
- Jest: functional component array list not mapping after adding element
- Using setState to dynamically populate an array of objects
- Argument of type 'undefined' is not assignable to parameter of type 'string | Blob'.ts(2345)
- Is it possible to combine talwind daisyUI with CSS variables?
- How can I open the mui KeyboardDatePicker dialog when the input field is clicked
- Redux - Is using getState not elegant or inefficient?
- React, why use super(props) inside of ES6 class constructor?
- ReactJS with Typescript not accepting Object with properties
- Remove Object out an Array
- How to use useEffect when there are dependencies I don't care about?
- Using ReactJS components properties in HTML attributes
- How'd I populate object key values when it comes to react hooks?
- mapping props is undefined when passed into component
- React Apollo Query keeps making network requests indefinitely with pollInterval
- How to remove event listener mousedown on component unmount using useeffect react hook?
- How to declare type of an array of a dynamic object as react state?
- Styling ReactSelect with CSS-in-JS
- Use string paths to images instead of requires when resolving img src and background-image urls
- How to reset array indexes in JavaScript array
- How can I map images in React from firebase storage?
- React Router Declared but doesn't work please
- GET_FAILURE in reducer test returns wrong in received
- Module not found: Can't resolve - React
- How to remove elements in an array based on their odd or even index?
- React native - objects are not valid as a React child (found: object with keys {$$typeof, type, key, ref, props, _owner, _store})
- How to Set a Fallback Value in React?
- want to load initial Values in Redux Form
- 'Can't perform a React state update on an unmounted component' ERROR when accessing the context api
- How to disable server side rendering on an asp.netcore-spa application?