goenning / google-indexing-script

Script to get your site indexed on Google in less than 48 hours
https://seogets.com
MIT License
6.96k stars 483 forks source link

TypeError: Cannot read properties of undefined (reading 'map') #12

Closed fema3832 closed 9 months ago

fema3832 commented 9 months ago

Hello! Can someone help me why this script is not working for me. I turned on Google Search Console API and Web Search Indexing API. I downloaded the user json which has owner permissions and renamed it service_account.json.

This is the error what i got every time:

> google-indexing-script@0.0.0 index
> node ./src/index.mjs panjandrum.hu

🔎 Processing site: sc-domain:panjandrum.hu
file:///C:/Users/Fema/Desktop/google-indexing-script-main/src/shared/sitemap.mjs:29
  return body.sitemap.map((x) => x.path);
                      ^

TypeError: Cannot read properties of undefined (reading 'map')
    at getSitemapsList (file:///C:/Users/Fema/Desktop/google-indexing-script-main/src/shared/sitemap.mjs:29:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getSitemapPages (file:///C:/Users/Fema/Desktop/google-indexing-script-main/src/shared/sitemap.mjs:33:20)
    at async file:///C:/Users/Fema/Desktop/google-indexing-script-main/src/index.mjs:27:27

Node.js v20.11.0

Thank you very much for your help in advance

Sivasish48 commented 9 months ago

Hello, I think the JavaScript code's review should be done to know where the error occurs, paying particular attention to the part where it accesses the 'sitemap' property. But first double-check the structure of the response from the Google APIs to ensure that it includes the expected 'sitemap' property. Then try the error handling.

qq280948982 commented 9 months ago

I have the same issue, and I found it needs to submit your sitemap to Google Search Console first, and try again will be works.

  1. Login your Google Search Console.
  2. Click the "Sitemaps" page on the left menu.
  3. Input your sitemap url and submit.
  4. Now try again running this script.

WX20240128-200722@2x