gridsome-starter-wordpress
gridsome-starter-wordpress copied to clipboard
TypeError: Cannot destructure property `status` of 'undefined' or 'null'.
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!
Getting this too, but only intermittently. Not every time.
I have the same issue.
@devellopah @seansmyth I found how to workaround. Inside gridsome.config.js, you need to add the baseUrl. It's not well explained.
@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.
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.
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;">Хостинг ХостиЯ. Сработала защита против взлома!</div>Если Вы видите это сообщение, Ваш браузер не поддерживает <b>JavaScript</b>!<br />Включите поддержку <b>JavaScript</b> в настройках браузера, чтобы страница загрузилась!</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;">Хостинг ХостиЯ. Сработала защита против взлома!</div>Если Вы видите это сообщение, Ваш браузер не поддерживает <b>Cookie</b>!<br />Включите поддержку <b>Cookie</b> в настройках браузера, чтобы страница загрузилась!</div>');}</script></body></html>
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
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)
This error should be fixed by https://github.com/gridsome/gridsome/pull/905
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?
What version is @gridsome/source-wordpress? I don't think @hjvedvik has published the updates yet...
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.
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.

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.
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.
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.