storyblok / storyblok-js

JavaScript SDK to connect Storyblok with your favourite framework that we don't have an official SDK for.
http://storyblok.com/
MIT License
39 stars 20 forks source link

Error log prints [object Object] #592

Open Kzoeps opened 1 month ago

Kzoeps commented 1 month ago

Describe the issue you're facing

While trying to pull components the error log prints out only [object Object]. I mistakenly set my space to 'us' although the actual storyblok space is in eu. This resulted in the api being something like this:

{
  accessToken: '',
  oauthToken: 'some_token_here',
  spaceId: '299747',
  region: '',
  getClient: [Function: getClient],
  getPath: [Function: getPath],
  login: [AsyncFunction: login],
  getUser: [AsyncFunction: getUser],
  persistCredentials: [Function: persistCredentials],
  processLogin: [AsyncFunction: processLogin],
  loginWithToken: [AsyncFunction: loginWithToken],
  logout: [Function: logout],
  signup: [Function: signup],
  isAuthorized: [Function: isAuthorized],
  setSpaceId: [Function: setSpaceId],
  setRegion: [Function: setRegion],
  getPresets: [Function: getPresets],
  getSpaceOptions: [Function: getSpaceOptions],
  getComponents: [Function: getComponents],
  getComponentGroups: [Function: getComponentGroups],
  getDatasources: [Function: getDatasources],
  deleteDatasource: [Function: deleteDatasource],
  post: [Function: post],
  put: [Function: put],
  get: [Function: get],
  getStories: [Function: getStories],
  getSingleStory: [Function: getSingleStory],
  delete: [Function: delete],
  sendRequest: [Function: sendRequest],
  getAllSpacesByRegion: [AsyncFunction: getAllSpacesByRegion],
  apiSwitcher: [Function: apiSwitcher]
}

And so when i tried to pull the components the error printed out by errorHandler was [object Object], since the original error is:

{
  message: 'Not Found',
  status: 404,
  response: 'This record could not be found'
}

Reproduction

https://no-link-idonthave-astorybloklink

Steps to reproduce

  1. create a storyblok
  2. set the space to eu
  3. when logging in through cli set space to 'us'
  4. pull components using: storyblok pull-components --space space_number
  5. error logged is [object Object]

System Info

System:
    OS: Linux 6.8 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (12) x64 AMD Ryzen 5 5500U with Radeon Graphics
    Memory: 2.83 GB / 13.47 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 18.17.1 - /usr/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 9.6.7 - /usr/bin/npm
    pnpm: 9.12.1 - ~/.local/share/pnpm/pnpm
  Browsers:
    Brave Browser: 128.1.69.168
    Chrome: 129.0.6668.100

Used Package Manager

pnpm

Error logs (Optional)

Validations