Answer the question
In order to leave comments, you need to log in
How to properly export a function\array?
Fetch get an array of users with jsonplaseholder. This array must be exported to another file and there you can already get what you need from the array (the name property of each of the users). Faced with the fact that the .map() method is not a function
const fetch = require("node-fetch");
module.exports = {
getMain1: async(req, res) => {
},
getMain2: new Promise(async function (resolve, reject) {
let response = await fetch('https://jsonplaceholder.typicode.com/users');
resolve(response.json());
reject();
}),
myValue: 'getMain2'
};
import {myValue} from './getPieData';
let dataForSeries = myValue.map(item => item.name.length);
export default {
options: {
chart: {
height: 350,
type: 'line'
},
dataLabels: {
enabled: false
}
},
series: [{
name: 'Pie Plot1',
type: 'area',
data: dataForSeries
}]
}
TypeError: _getPieData__WEBPACK_IMPORTED_MODULE_0__.myValue.map is not a function
Module../src/components/Pie/PieData.js
C:/Dev/chartsandtable/src/components/Pie/PieData.js:3
1 | import {myValue} from './getPieData';
2 |
> 3 | let dataForSeries = myValue.map(item => item.name.length);
4 |
5 | export default {
6 | options: {
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question