Skip to content

Error getting Grid Section #39

@sea-sol

Description

@sea-sol
Grid catch TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
    at GridSectionClient.<anonymous> (fetch.ts:16:1)
    at step (error.ts:49:1)
    at Object.next (error.ts:49:1)
    at error.ts:49:1
    at new Promise (<anonymous>)
    at globalThis.webpackHotUpdatenft_city../node_modules/@what3words/api/dist/lib/transport/fetch.js.__awaiter (error.ts:49:1)
    at GridSectionClient.fetchTransport [as transport] (fetch.ts:8:1)
    at GridSectionClient.<anonymous> (abstract.ts:80:1)
    at step (index.ts:5:1)
    at Object.next (index.ts:5:1)

here is my code

import what3words, { GridSectionClient, GridSectionOptions } from '@what3words/api';


const API_KEY = 'IBC4C9WV';
    const client = GridSectionClient.init(API_KEY);
    const options = {
      boundingBox: {
        southwest: { lat: 52.208867, lng: 0.117540 },
        northeast: { lat: 52.207988, lng: 0.116126 }
      }
    };
    client.run(options)
      .then((res) => console.log('Grid Section', res)).catch((res) => console.log('Grid catch', res));

and if I change code like this,

const API_KEY = 'IBC4C9WV';
    const client = GridSectionClient.init(API_KEY);
    const options = {
        southwest: { lat: 52.208867, lng: 0.117540 },
        northeast: { lat: 52.207988, lng: 0.116126 }
    };
    client.run(options)
      .then((res) => console.log('Grid Section', res)).catch((res) => console.log('Grid catch', res));

the result is

Grid catch Error: No bounding box specified
    at GridSectionClient.<anonymous> (abstract.ts:50:1)
    at step (index.ts:5:1)
    at Object.next (index.ts:5:1)
    at fulfilled (index.ts:5:1)

how can I fix and get correct result?

this is my package.json

{
  "name": "nft-city",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.3.0-beta3",
    "@fortawesome/free-solid-svg-icons": "^6.0.0-beta3",
    "@fortawesome/react-fontawesome": "^0.1.16",
    "@testing-library/jest-dom": "^5.16.1",
    "@testing-library/react": "^12.1.2",
    "@testing-library/user-event": "^13.5.0",
    "@what3words/api": "^4.0.4",
    "axios": "^0.25.0",
    "isomorphic-unfetch": "^3.1.0",
    "mapbox-gl": "^2.6.1",
    "os": "^0.1.2",
    "react": "^17.0.2",
    "react-cookie": "^4.1.1",
    "react-dom": "^17.0.2",
    "react-expand-animated": "^1.0.2",
    "react-helmet": "^6.1.0",
    "react-map-gl": "^6.1.18",
    "react-map-gl-geocoder": "^2.2.0",
    "react-router-dom": "^6.2.1",
    "react-scripts": "5.0.0",
    "react-seekbar-component": "^1.0.0",
    "sass": "^1.48.0",
    "web-vitals": "^2.1.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts --max_old_space_size=4096 build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "autoprefixer": "^10.4.2",
    "postcss": "^8.4.5",
    "tailwindcss": "^3.0.15"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions