gridsome-starter-wordpress icon indicating copy to clipboard operation
gridsome-starter-wordpress copied to clipboard

TypeError: Cannot destructure property `status` of 'undefined' or 'null'.

Open devellopah opened this issue 6 years ago • 16 comments
trafficstars

I am trying to fetch data from wordpress site, located on subdomain of my personal site.

I have created .env file in the root directory of project, inside which i have added WORDPRESS_URL=https://woo.islamibakaev.ru/

On yarn develop i get this output in terminal

yarn run v1.17.3
$ gridsome develop
Gridsome v0.7.3

Initializing plugins...
Loading data from https://woo.islamibakaev.ru
TypeError: Cannot destructure property `status` of 'undefined' or 'null'.
    at WordPressSource.fetch (/home/devellopah/projects/vue/vue-wordpress/node_modules/@gridsome/source-wordpress/index.js:169:40)
    at process._tickCallback (internal/process/next_tick.js:68:7)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Please help to figure out the issue. Thanks in advance!

devellopah avatar Sep 21 '19 22:09 devellopah

Getting this too, but only intermittently. Not every time.

seansmyth avatar Oct 22 '19 16:10 seansmyth

I have the same issue.

vvnsrzn avatar Oct 29 '19 16:10 vvnsrzn

@devellopah @seansmyth I found how to workaround. Inside gridsome.config.js, you need to add the baseUrl. It's not well explained.

vvnsrzn avatar Oct 29 '19 17:10 vvnsrzn

@devellopah @seansmyth I found how to workaround. Inside gridsome.config.js, you need to add the baseUrl. It's not well explained.

It hasn't fixed the issue for me.

stephdumais666 avatar Oct 30 '19 20:10 stephdumais666

I modified the plugin file to test out possible avenues for a solution. Line 171 seems to be where it breaks: const { status } = response.data.data

Above that line I added:

  console.warn(response);

And the error printed out is a 403 status produced by the wordpress url */wp-json/wp/v2/users

I don't know what the next step is but it's a start.

stephdumais666 avatar Oct 30 '19 20:10 stephdumais666

console.warn(response.data) gives me html string no property data on response.data is available

Initializing plugins...
Loading data from https://woo.islamibakaev.ru
response <html><head><meta http-equiv='refresh' content='1'></head><body><script type='text/javascript' src='//woo.islamibakaev.ru/hostia-antibot.js'></script><noscript><div align="center" style="color:#a16c18;font-family:'Arial';line-height:28px;"><div style="font-size:18px;font-weight:600;font-family:'Arial';color:#fe6e0e;margin:50px 0px 15px 0px;">&#1061;&#1086;&#1089;&#1090;&#1080;&#1085;&#1075; &#1061;&#1086;&#1089;&#1090;&#1080;&#1071;. &#1057;&#1088;&#1072;&#1073;&#1086;&#1090;&#1072;&#1083;&#1072; &#1079;&#1072;&#1097;&#1080;&#1090;&#1072; &#1087;&#1088;&#1086;&#1090;&#1080;&#1074; &#1074;&#1079;&#1083;&#1086;&#1084;&#1072;!</div>&#1045;&#1089;&#1083;&#1080; &#1042;&#1099; &#1074;&#1080;&#1076;&#1080;&#1090;&#1077; &#1101;&#1090;&#1086; &#1089;&#1086;&#1086;&#1073;&#1097;&#1077;&#1085;&#1080;&#1077;, &#1042;&#1072;&#1096; &#1073;&#1088;&#1072;&#1091;&#1079;&#1077;&#1088; &#1085;&#1077; &#1087;&#1086;&#1076;&#1076;&#1077;&#1088;&#1078;&#1080;&#1074;&#1072;&#1077;&#1090; <b>JavaScript</b>!<br />&#1042;&#1082;&#1083;&#1102;&#1095;&#1080;&#1090;&#1077; &#1087;&#1086;&#1076;&#1076;&#1077;&#1088;&#1078;&#1082;&#1091; <b>JavaScript</b> &#1074; &#1085;&#1072;&#1089;&#1090;&#1088;&#1086;&#1081;&#1082;&#1072;&#1093; &#1073;&#1088;&#1072;&#1091;&#1079;&#1077;&#1088;&#1072;, &#1095;&#1090;&#1086;&#1073;&#1099; &#1089;&#1090;&#1088;&#1072;&#1085;&#1080;&#1094;&#1072; &#1079;&#1072;&#1075;&#1088;&#1091;&#1079;&#1080;&#1083;&#1072;&#1089;&#1100;!</div></noscript><script>if (!navigator.cookieEnabled) {document.write('<div align="center" style="color:#a16c18;font-family:Arial;line-height:28px;"><div style="font-size:18px;font-weight:600;font-family:Arial;color:#fe6e0e;margin:50px 0px 15px 0px;">&#1061;&#1086;&#1089;&#1090;&#1080;&#1085;&#1075; &#1061;&#1086;&#1089;&#1090;&#1080;&#1071;. &#1057;&#1088;&#1072;&#1073;&#1086;&#1090;&#1072;&#1083;&#1072; &#1079;&#1072;&#1097;&#1080;&#1090;&#1072; &#1087;&#1088;&#1086;&#1090;&#1080;&#1074; &#1074;&#1079;&#1083;&#1086;&#1084;&#1072;!</div>&#1045;&#1089;&#1083;&#1080; &#1042;&#1099; &#1074;&#1080;&#1076;&#1080;&#1090;&#1077; &#1101;&#1090;&#1086; &#1089;&#1086;&#1086;&#1073;&#1097;&#1077;&#1085;&#1080;&#1077;, &#1042;&#1072;&#1096; &#1073;&#1088;&#1072;&#1091;&#1079;&#1077;&#1088; &#1085;&#1077; &#1087;&#1086;&#1076;&#1076;&#1077;&#1088;&#1078;&#1080;&#1074;&#1072;&#1077;&#1090; <b>Cookie</b>!<br />&#1042;&#1082;&#1083;&#1102;&#1095;&#1080;&#1090;&#1077; &#1087;&#1086;&#1076;&#1076;&#1077;&#1088;&#1078;&#1082;&#1091; <b>Cookie</b> &#1074; &#1085;&#1072;&#1089;&#1090;&#1088;&#1086;&#1081;&#1082;&#1072;&#1093; &#1073;&#1088;&#1072;&#1091;&#1079;&#1077;&#1088;&#1072;, &#1095;&#1090;&#1086;&#1073;&#1099; &#1089;&#1090;&#1088;&#1072;&#1085;&#1080;&#1094;&#1072; &#1079;&#1072;&#1075;&#1088;&#1091;&#1079;&#1080;&#1083;&#1072;&#1089;&#1100;!</div>');}</script></body></html>

devellopah avatar Oct 30 '19 22:10 devellopah

status is available at response itself, so looks like const { status } = response.data.data
needs to be replaced with
const { status } = response
but then i get error Error: 412 - https://woo.islamibakaev.ru/wp-json/wp/v2/media

devellopah avatar Oct 30 '19 22:10 devellopah

Did someone found a fix for this ? I didn't even start developing and after installing with gridsome create project wordpress, created a .env file and ran gridsome develop got the same error

TypeError: Cannot destructure property `status` of 'undefined' or 'null'.
    at WordPressSource.fetch (/home/pedroferreira/Documents/Projetos/imo/wp-content/themes/imo-gridsome/imo-zalox/node_modules/@gridsome/source-wordpress/index.js:171:40)
    at process._tickCallback (internal/process/next_tick.js:68:7)

pedrofmiguel avatar Dec 27 '19 11:12 pedrofmiguel

This error should be fixed by https://github.com/gridsome/gridsome/pull/905

travis-r6s avatar Dec 27 '19 18:12 travis-r6s

Unfortunately, it seems that the fix is not working in my case.

OS: elementaryOS Hera 5.1
node: v10.16.0
@gridsome/cli: v0.3.1
gridsome: v0.7.12

Any new ideas perhaps?

WebShapedBiz avatar Jan 14 '20 07:01 WebShapedBiz

What version is @gridsome/source-wordpress? I don't think @hjvedvik has published the updates yet...

travis-r6s avatar Jan 14 '20 13:01 travis-r6s

Thank you @thetre97 for your quick reply and sorry I forgot to mention, the version of @gridsome/source-wordpress is 0.5.2. I was afraid that the latest commit wasn't published yet so I've downloaded and replaced index.js but that resulted in a different error so I stopped digging myself deeper.

Cheers.

WebShapedBiz avatar Jan 14 '20 13:01 WebShapedBiz

I changed my date format in Wordpress away from the first option (F j, Y) to the second option (arbitrarily chosen, Y-m-d). and This was resolved for me.

image

zekecato avatar Jan 31 '20 21:01 zekecato

It hasn't fixed the issue for me.

Nor my either.

But looking deeper into my gridsome.config.js file I see my defaults need updating such as: use: '~/src/plugins/wp-source/', the tilde would link to your users home directory, but once I corrected to in my case:

use: '/Users/tom/Dropbox/Sites/therockfactory.net/', // was originally set to ~/src/plugins/wp-source/

Boom! It's working. Sort of.

tomachinz avatar Feb 13 '20 05:02 tomachinz

I had another site where this wasn't working. Besides changing the date format, I see that I also needed to change my permalink settings in WordPress away from the 'Plain' format. That got me past this error on my second site.

zekecato avatar Feb 14 '20 21:02 zekecato

TypeError: Cannot destructure property 'product' of 'productDetails' as it is undefined. function ProductScreen(props) { 7 | const [qty, setQty] = useState(1); 8 | const productDetails = useSelector((state) => state.productDetails);

9 | const { product,loading,error } = productDetails; 10 | const dispatch = useDispatch(); 11 | 12 | useEffect(()=>{ View compiled ▶ 16 stack frames were collapsed.

Meignanam avatar Sep 13 '20 07:09 Meignanam