So I have the following code which is returning me an array with other three arrays instead returning an array with objects only. Any way to get that done?
Here is the returning response where I would like to keep just the main Array with objects only
Array [
Array [
Object {
"_id": "5b276afd8d05600a78e91fea",
"description": "",
"location": Array [
Object {
"_id": "5b276afd8d05600a78e91feb",
"city": "London",
},
],
"postDate": "2018-06-18T08:18:16.893Z",
"title": "Post Michael 1",
},
Object {
"_id": "5b276c35bab2220ae8ec8859",
"description": "",
"location": Array [
Object {
"_id": "5b276c35bab2220ae8ec885a",
"city": "London",
},
],
"postDate": "2018-06-18T08:18:16.893Z",
"title": "Post Michael 2",
},
],
Array [],
Array [
Object {
"_id": "5b27a44b91b02c10450fef7e",
"description": "",
"location": Array [
Object {
"_id": "5b27a44b91b02c10450fef7f",
"city": "London",
},
],
"postDate": "2018-06-18T12:23:32.508Z",
"title": "Post Sarah 1",
},
],
]
Here is my function thats returning this
export function getAllJobs(dispatch, getState) {
const state = getState();
const { token } = state.auth;
return axios.get(JOBS_ALL_URL, {
headers: { authorization: token }
}).then((response) => {
var result = [];
response.data.map(o => {
result.push(o.jobs);
});
console.log(result);
dispatch(setJobs(result));
}).catch((err) => {
dispatch(console.log("Couldn't get jobs."));
});
}