Handling errors of undefined URLs
My frontend log is full of these errors.
When I hit any undefined address I got this in my terminal (in the vscode not in the browser).
The main problem is I'm not sure how to handle errors that are caused by hitting an undefined url. For example here I know that /ca/en/category
is undefined and doesn't exist but I don't know how to stop js from trying to map this undefined URL.
error: {
"requestedPath": "/ca/en/category", (or any other unefined address)
"errorMessage": "Cannot read property 'map' of undefined",
"clientIp": "::1"
}
TypeError: Cannot read property 'map' of undefined
at Chrome.module.exports../src/components/Chrome.tsx.Chrome.render (...distserver.js:518:916)
at processChild (...node_modulesreact-domcjsreact-dom-server.node.development.js:2207:18)
at resolve (...node_modulesreact-domcjsreact-dom-server.node.development.js:2064:5)
at ReactDOMServerRenderer.render (...node_modulesreact-domcjsreact-dom-server.node.development.js:2383:22)
at ReactDOMServerRenderer.read (...react-domcjsreact-dom-server.node.development.js:2357:19)
at Object.renderToString (...node_modulesreact-domcjsreact-dom-server.node.development.js:2729:25)
at...distserver.js:4346:69
at step (...node_modulestslibtslib.js:133:27)
at Object.next (...node_modulestslibtslib.js:114:57)
at fulfilled (...enode_modulestslibtslib.js:104:62)
and here is how I'm building addresses (for category):
if (pathname.startsWith('/category/')) {
const cat = menu.find(({ slug }) => pathname.startsWith('/category/' + slug));
if (cat) {
leftBar = cat.subcategories.map(({ name, productLines, slug: subSlug }) => ({
title: name,
path: `/category/${cat.slug}/${subSlug}`,
links: productLines.map(({ name, slug }) => ({
title: name,
path: `/category/${cat.slug}/${subSlug}/${slug}`,
})),
}));
leftBarTitle = cat.name;
}
}
and I have a server,js file and in line 518 I have:
return _react2.default.createElement(_react2.default.Fragment, null, banner && this.state.bannerOpen ? _react2.default.createElement(_Banner2.default, { banner: banner, onClose: this.handleBannerClose }) : null, _react2.default.createElement("div", { className: classes.frame }, _react2.default.createElement(_CssBaseline2.default, null), _react2.default.createElement(_TopBar2.default, null), _react2.default.createElement("div", { className: classes.container, id: "container" }, _react2.default.createElement("div", { className: classes.content }, children), pathname.startsWith('/category') && _react2.default.createElement("div", { className: classes.leftBar }, leftBarTitle && _react2.default.createElement(_react2.default.Fragment, null, _react2.default.createElement(_Typography2.default, { variant: "headline", component: "span" }, leftBarTitle), _react2.default.createElement("p", null)), leftBar.map(function (_a, i) {
var title = _a.title,
path = _a.path,
links = _a.links;
I think there shouldn't be errors like this in the terminal but I'm not sure how to handle it.
javascript reactjs error-handling routing
add a comment |
My frontend log is full of these errors.
When I hit any undefined address I got this in my terminal (in the vscode not in the browser).
The main problem is I'm not sure how to handle errors that are caused by hitting an undefined url. For example here I know that /ca/en/category
is undefined and doesn't exist but I don't know how to stop js from trying to map this undefined URL.
error: {
"requestedPath": "/ca/en/category", (or any other unefined address)
"errorMessage": "Cannot read property 'map' of undefined",
"clientIp": "::1"
}
TypeError: Cannot read property 'map' of undefined
at Chrome.module.exports../src/components/Chrome.tsx.Chrome.render (...distserver.js:518:916)
at processChild (...node_modulesreact-domcjsreact-dom-server.node.development.js:2207:18)
at resolve (...node_modulesreact-domcjsreact-dom-server.node.development.js:2064:5)
at ReactDOMServerRenderer.render (...node_modulesreact-domcjsreact-dom-server.node.development.js:2383:22)
at ReactDOMServerRenderer.read (...react-domcjsreact-dom-server.node.development.js:2357:19)
at Object.renderToString (...node_modulesreact-domcjsreact-dom-server.node.development.js:2729:25)
at...distserver.js:4346:69
at step (...node_modulestslibtslib.js:133:27)
at Object.next (...node_modulestslibtslib.js:114:57)
at fulfilled (...enode_modulestslibtslib.js:104:62)
and here is how I'm building addresses (for category):
if (pathname.startsWith('/category/')) {
const cat = menu.find(({ slug }) => pathname.startsWith('/category/' + slug));
if (cat) {
leftBar = cat.subcategories.map(({ name, productLines, slug: subSlug }) => ({
title: name,
path: `/category/${cat.slug}/${subSlug}`,
links: productLines.map(({ name, slug }) => ({
title: name,
path: `/category/${cat.slug}/${subSlug}/${slug}`,
})),
}));
leftBarTitle = cat.name;
}
}
and I have a server,js file and in line 518 I have:
return _react2.default.createElement(_react2.default.Fragment, null, banner && this.state.bannerOpen ? _react2.default.createElement(_Banner2.default, { banner: banner, onClose: this.handleBannerClose }) : null, _react2.default.createElement("div", { className: classes.frame }, _react2.default.createElement(_CssBaseline2.default, null), _react2.default.createElement(_TopBar2.default, null), _react2.default.createElement("div", { className: classes.container, id: "container" }, _react2.default.createElement("div", { className: classes.content }, children), pathname.startsWith('/category') && _react2.default.createElement("div", { className: classes.leftBar }, leftBarTitle && _react2.default.createElement(_react2.default.Fragment, null, _react2.default.createElement(_Typography2.default, { variant: "headline", component: "span" }, leftBarTitle), _react2.default.createElement("p", null)), leftBar.map(function (_a, i) {
var title = _a.title,
path = _a.path,
links = _a.links;
I think there shouldn't be errors like this in the terminal but I'm not sure how to handle it.
javascript reactjs error-handling routing
Just means one of the values you are mapping over dosnt exist. Either cat.subcategories, or productlines. Putting in some console logs on those should reveal what's going one, they need to be arrays.
– SpeedOfRound
Nov 23 '18 at 18:22
@SpeedOfRound I don't have /category url and I think that's why it is throwing this error. I just don't know have to handle it. Because I don't want the errors to be in my terminal.
– Hanna
Nov 23 '18 at 18:27
changing your third line to if (cat.subcategories) Should prevent you from getting to that step
– SpeedOfRound
Nov 23 '18 at 18:29
@HardikModha I'm asking about how to handle undefined url errors not ` Cannot read property 'map' of undefined`
– Hanna
Nov 23 '18 at 18:34
This is when you run the map method over a variable which is not an array.
– Markus Zeller
Nov 23 '18 at 19:04
add a comment |
My frontend log is full of these errors.
When I hit any undefined address I got this in my terminal (in the vscode not in the browser).
The main problem is I'm not sure how to handle errors that are caused by hitting an undefined url. For example here I know that /ca/en/category
is undefined and doesn't exist but I don't know how to stop js from trying to map this undefined URL.
error: {
"requestedPath": "/ca/en/category", (or any other unefined address)
"errorMessage": "Cannot read property 'map' of undefined",
"clientIp": "::1"
}
TypeError: Cannot read property 'map' of undefined
at Chrome.module.exports../src/components/Chrome.tsx.Chrome.render (...distserver.js:518:916)
at processChild (...node_modulesreact-domcjsreact-dom-server.node.development.js:2207:18)
at resolve (...node_modulesreact-domcjsreact-dom-server.node.development.js:2064:5)
at ReactDOMServerRenderer.render (...node_modulesreact-domcjsreact-dom-server.node.development.js:2383:22)
at ReactDOMServerRenderer.read (...react-domcjsreact-dom-server.node.development.js:2357:19)
at Object.renderToString (...node_modulesreact-domcjsreact-dom-server.node.development.js:2729:25)
at...distserver.js:4346:69
at step (...node_modulestslibtslib.js:133:27)
at Object.next (...node_modulestslibtslib.js:114:57)
at fulfilled (...enode_modulestslibtslib.js:104:62)
and here is how I'm building addresses (for category):
if (pathname.startsWith('/category/')) {
const cat = menu.find(({ slug }) => pathname.startsWith('/category/' + slug));
if (cat) {
leftBar = cat.subcategories.map(({ name, productLines, slug: subSlug }) => ({
title: name,
path: `/category/${cat.slug}/${subSlug}`,
links: productLines.map(({ name, slug }) => ({
title: name,
path: `/category/${cat.slug}/${subSlug}/${slug}`,
})),
}));
leftBarTitle = cat.name;
}
}
and I have a server,js file and in line 518 I have:
return _react2.default.createElement(_react2.default.Fragment, null, banner && this.state.bannerOpen ? _react2.default.createElement(_Banner2.default, { banner: banner, onClose: this.handleBannerClose }) : null, _react2.default.createElement("div", { className: classes.frame }, _react2.default.createElement(_CssBaseline2.default, null), _react2.default.createElement(_TopBar2.default, null), _react2.default.createElement("div", { className: classes.container, id: "container" }, _react2.default.createElement("div", { className: classes.content }, children), pathname.startsWith('/category') && _react2.default.createElement("div", { className: classes.leftBar }, leftBarTitle && _react2.default.createElement(_react2.default.Fragment, null, _react2.default.createElement(_Typography2.default, { variant: "headline", component: "span" }, leftBarTitle), _react2.default.createElement("p", null)), leftBar.map(function (_a, i) {
var title = _a.title,
path = _a.path,
links = _a.links;
I think there shouldn't be errors like this in the terminal but I'm not sure how to handle it.
javascript reactjs error-handling routing
My frontend log is full of these errors.
When I hit any undefined address I got this in my terminal (in the vscode not in the browser).
The main problem is I'm not sure how to handle errors that are caused by hitting an undefined url. For example here I know that /ca/en/category
is undefined and doesn't exist but I don't know how to stop js from trying to map this undefined URL.
error: {
"requestedPath": "/ca/en/category", (or any other unefined address)
"errorMessage": "Cannot read property 'map' of undefined",
"clientIp": "::1"
}
TypeError: Cannot read property 'map' of undefined
at Chrome.module.exports../src/components/Chrome.tsx.Chrome.render (...distserver.js:518:916)
at processChild (...node_modulesreact-domcjsreact-dom-server.node.development.js:2207:18)
at resolve (...node_modulesreact-domcjsreact-dom-server.node.development.js:2064:5)
at ReactDOMServerRenderer.render (...node_modulesreact-domcjsreact-dom-server.node.development.js:2383:22)
at ReactDOMServerRenderer.read (...react-domcjsreact-dom-server.node.development.js:2357:19)
at Object.renderToString (...node_modulesreact-domcjsreact-dom-server.node.development.js:2729:25)
at...distserver.js:4346:69
at step (...node_modulestslibtslib.js:133:27)
at Object.next (...node_modulestslibtslib.js:114:57)
at fulfilled (...enode_modulestslibtslib.js:104:62)
and here is how I'm building addresses (for category):
if (pathname.startsWith('/category/')) {
const cat = menu.find(({ slug }) => pathname.startsWith('/category/' + slug));
if (cat) {
leftBar = cat.subcategories.map(({ name, productLines, slug: subSlug }) => ({
title: name,
path: `/category/${cat.slug}/${subSlug}`,
links: productLines.map(({ name, slug }) => ({
title: name,
path: `/category/${cat.slug}/${subSlug}/${slug}`,
})),
}));
leftBarTitle = cat.name;
}
}
and I have a server,js file and in line 518 I have:
return _react2.default.createElement(_react2.default.Fragment, null, banner && this.state.bannerOpen ? _react2.default.createElement(_Banner2.default, { banner: banner, onClose: this.handleBannerClose }) : null, _react2.default.createElement("div", { className: classes.frame }, _react2.default.createElement(_CssBaseline2.default, null), _react2.default.createElement(_TopBar2.default, null), _react2.default.createElement("div", { className: classes.container, id: "container" }, _react2.default.createElement("div", { className: classes.content }, children), pathname.startsWith('/category') && _react2.default.createElement("div", { className: classes.leftBar }, leftBarTitle && _react2.default.createElement(_react2.default.Fragment, null, _react2.default.createElement(_Typography2.default, { variant: "headline", component: "span" }, leftBarTitle), _react2.default.createElement("p", null)), leftBar.map(function (_a, i) {
var title = _a.title,
path = _a.path,
links = _a.links;
I think there shouldn't be errors like this in the terminal but I'm not sure how to handle it.
javascript reactjs error-handling routing
javascript reactjs error-handling routing
edited Nov 23 '18 at 18:59
Hanna
asked Nov 23 '18 at 18:18
HannaHanna
268417
268417
Just means one of the values you are mapping over dosnt exist. Either cat.subcategories, or productlines. Putting in some console logs on those should reveal what's going one, they need to be arrays.
– SpeedOfRound
Nov 23 '18 at 18:22
@SpeedOfRound I don't have /category url and I think that's why it is throwing this error. I just don't know have to handle it. Because I don't want the errors to be in my terminal.
– Hanna
Nov 23 '18 at 18:27
changing your third line to if (cat.subcategories) Should prevent you from getting to that step
– SpeedOfRound
Nov 23 '18 at 18:29
@HardikModha I'm asking about how to handle undefined url errors not ` Cannot read property 'map' of undefined`
– Hanna
Nov 23 '18 at 18:34
This is when you run the map method over a variable which is not an array.
– Markus Zeller
Nov 23 '18 at 19:04
add a comment |
Just means one of the values you are mapping over dosnt exist. Either cat.subcategories, or productlines. Putting in some console logs on those should reveal what's going one, they need to be arrays.
– SpeedOfRound
Nov 23 '18 at 18:22
@SpeedOfRound I don't have /category url and I think that's why it is throwing this error. I just don't know have to handle it. Because I don't want the errors to be in my terminal.
– Hanna
Nov 23 '18 at 18:27
changing your third line to if (cat.subcategories) Should prevent you from getting to that step
– SpeedOfRound
Nov 23 '18 at 18:29
@HardikModha I'm asking about how to handle undefined url errors not ` Cannot read property 'map' of undefined`
– Hanna
Nov 23 '18 at 18:34
This is when you run the map method over a variable which is not an array.
– Markus Zeller
Nov 23 '18 at 19:04
Just means one of the values you are mapping over dosnt exist. Either cat.subcategories, or productlines. Putting in some console logs on those should reveal what's going one, they need to be arrays.
– SpeedOfRound
Nov 23 '18 at 18:22
Just means one of the values you are mapping over dosnt exist. Either cat.subcategories, or productlines. Putting in some console logs on those should reveal what's going one, they need to be arrays.
– SpeedOfRound
Nov 23 '18 at 18:22
@SpeedOfRound I don't have /category url and I think that's why it is throwing this error. I just don't know have to handle it. Because I don't want the errors to be in my terminal.
– Hanna
Nov 23 '18 at 18:27
@SpeedOfRound I don't have /category url and I think that's why it is throwing this error. I just don't know have to handle it. Because I don't want the errors to be in my terminal.
– Hanna
Nov 23 '18 at 18:27
changing your third line to if (cat.subcategories) Should prevent you from getting to that step
– SpeedOfRound
Nov 23 '18 at 18:29
changing your third line to if (cat.subcategories) Should prevent you from getting to that step
– SpeedOfRound
Nov 23 '18 at 18:29
@HardikModha I'm asking about how to handle undefined url errors not ` Cannot read property 'map' of undefined`
– Hanna
Nov 23 '18 at 18:34
@HardikModha I'm asking about how to handle undefined url errors not ` Cannot read property 'map' of undefined`
– Hanna
Nov 23 '18 at 18:34
This is when you run the map method over a variable which is not an array.
– Markus Zeller
Nov 23 '18 at 19:04
This is when you run the map method over a variable which is not an array.
– Markus Zeller
Nov 23 '18 at 19:04
add a comment |
3 Answers
3
active
oldest
votes
just try this code and look where you try to map undefined
object
if(!cat.subcategories) console.log('not exist but i try to map')
cat.subcategories.map(({ name, productLines, slug: subSlug }) => {
if(!productLines) console.log('not exist but i try to map')
})`
I added the code but I'm not seeing any output of it.
– Hanna
Nov 26 '18 at 16:08
add a comment |
you can validate with:
if(!cat.subcategories) return
` Cannot read property 'subcategories' of undefined` when I'm hitting an undefined url
– Hanna
Nov 26 '18 at 16:11
I also triedif(!cat) return
and the result isNothing was returned from render.
– Hanna
Nov 26 '18 at 16:18
add a comment |
In render you always need to return something so that's the way I solved the issue:
if (cat) {....
} else {
return <Redirect to="/" />;
doing so, it will redirect me to an address and won't give me Nothing was returned from render.
anymore.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451384%2fhandling-errors-of-undefined-urls%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
just try this code and look where you try to map undefined
object
if(!cat.subcategories) console.log('not exist but i try to map')
cat.subcategories.map(({ name, productLines, slug: subSlug }) => {
if(!productLines) console.log('not exist but i try to map')
})`
I added the code but I'm not seeing any output of it.
– Hanna
Nov 26 '18 at 16:08
add a comment |
just try this code and look where you try to map undefined
object
if(!cat.subcategories) console.log('not exist but i try to map')
cat.subcategories.map(({ name, productLines, slug: subSlug }) => {
if(!productLines) console.log('not exist but i try to map')
})`
I added the code but I'm not seeing any output of it.
– Hanna
Nov 26 '18 at 16:08
add a comment |
just try this code and look where you try to map undefined
object
if(!cat.subcategories) console.log('not exist but i try to map')
cat.subcategories.map(({ name, productLines, slug: subSlug }) => {
if(!productLines) console.log('not exist but i try to map')
})`
just try this code and look where you try to map undefined
object
if(!cat.subcategories) console.log('not exist but i try to map')
cat.subcategories.map(({ name, productLines, slug: subSlug }) => {
if(!productLines) console.log('not exist but i try to map')
})`
answered Nov 23 '18 at 22:45
MichalMichal
111
111
I added the code but I'm not seeing any output of it.
– Hanna
Nov 26 '18 at 16:08
add a comment |
I added the code but I'm not seeing any output of it.
– Hanna
Nov 26 '18 at 16:08
I added the code but I'm not seeing any output of it.
– Hanna
Nov 26 '18 at 16:08
I added the code but I'm not seeing any output of it.
– Hanna
Nov 26 '18 at 16:08
add a comment |
you can validate with:
if(!cat.subcategories) return
` Cannot read property 'subcategories' of undefined` when I'm hitting an undefined url
– Hanna
Nov 26 '18 at 16:11
I also triedif(!cat) return
and the result isNothing was returned from render.
– Hanna
Nov 26 '18 at 16:18
add a comment |
you can validate with:
if(!cat.subcategories) return
` Cannot read property 'subcategories' of undefined` when I'm hitting an undefined url
– Hanna
Nov 26 '18 at 16:11
I also triedif(!cat) return
and the result isNothing was returned from render.
– Hanna
Nov 26 '18 at 16:18
add a comment |
you can validate with:
if(!cat.subcategories) return
you can validate with:
if(!cat.subcategories) return
answered Nov 24 '18 at 3:09
Fernando ColomFernando Colom
1312
1312
` Cannot read property 'subcategories' of undefined` when I'm hitting an undefined url
– Hanna
Nov 26 '18 at 16:11
I also triedif(!cat) return
and the result isNothing was returned from render.
– Hanna
Nov 26 '18 at 16:18
add a comment |
` Cannot read property 'subcategories' of undefined` when I'm hitting an undefined url
– Hanna
Nov 26 '18 at 16:11
I also triedif(!cat) return
and the result isNothing was returned from render.
– Hanna
Nov 26 '18 at 16:18
` Cannot read property 'subcategories' of undefined` when I'm hitting an undefined url
– Hanna
Nov 26 '18 at 16:11
` Cannot read property 'subcategories' of undefined` when I'm hitting an undefined url
– Hanna
Nov 26 '18 at 16:11
I also tried
if(!cat) return
and the result is Nothing was returned from render.
– Hanna
Nov 26 '18 at 16:18
I also tried
if(!cat) return
and the result is Nothing was returned from render.
– Hanna
Nov 26 '18 at 16:18
add a comment |
In render you always need to return something so that's the way I solved the issue:
if (cat) {....
} else {
return <Redirect to="/" />;
doing so, it will redirect me to an address and won't give me Nothing was returned from render.
anymore.
add a comment |
In render you always need to return something so that's the way I solved the issue:
if (cat) {....
} else {
return <Redirect to="/" />;
doing so, it will redirect me to an address and won't give me Nothing was returned from render.
anymore.
add a comment |
In render you always need to return something so that's the way I solved the issue:
if (cat) {....
} else {
return <Redirect to="/" />;
doing so, it will redirect me to an address and won't give me Nothing was returned from render.
anymore.
In render you always need to return something so that's the way I solved the issue:
if (cat) {....
} else {
return <Redirect to="/" />;
doing so, it will redirect me to an address and won't give me Nothing was returned from render.
anymore.
answered Nov 30 '18 at 16:40
HannaHanna
268417
268417
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53451384%2fhandling-errors-of-undefined-urls%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Just means one of the values you are mapping over dosnt exist. Either cat.subcategories, or productlines. Putting in some console logs on those should reveal what's going one, they need to be arrays.
– SpeedOfRound
Nov 23 '18 at 18:22
@SpeedOfRound I don't have /category url and I think that's why it is throwing this error. I just don't know have to handle it. Because I don't want the errors to be in my terminal.
– Hanna
Nov 23 '18 at 18:27
changing your third line to if (cat.subcategories) Should prevent you from getting to that step
– SpeedOfRound
Nov 23 '18 at 18:29
@HardikModha I'm asking about how to handle undefined url errors not ` Cannot read property 'map' of undefined`
– Hanna
Nov 23 '18 at 18:34
This is when you run the map method over a variable which is not an array.
– Markus Zeller
Nov 23 '18 at 19:04