Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
devellopah opened this issue Sep 21, 2019 · 16 comments
Open

Comments

@devellopah
Copy link

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!

@seansmyth
Copy link

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

@VivianSolide
Copy link

I have the same issue.

@VivianSolide
Copy link

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

@stephdumais666
Copy link

@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
Copy link

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.

@devellopah
Copy link
Author

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
Copy link
Author

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

@pedrofmiguel
Copy link

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)

@travis-r6s
Copy link
Member

travis-r6s commented Dec 27, 2019

This error should be fixed by gridsome/gridsome#905

@WebShapedBiz
Copy link

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?

@travis-r6s
Copy link
Member

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

@WebShapedBiz
Copy link

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.

@zekecato
Copy link

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

@tomachinz
Copy link

tomachinz commented Feb 13, 2020

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.

@zekecato
Copy link

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.

@Meignanam
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants