storyblok / wordpress-importer

A simple script for migrating content from WordPress to Storyblok.
MIT License
17 stars 12 forks source link

Can not run #1

Closed jamaluddinrumi closed 3 years ago

jamaluddinrumi commented 3 years ago

i want to import my live wordpress website at https://www.indomascot.com

i use this code below

import { Wp2Storyblok } from "./index.js";

const wp2storyblok = new Wp2Storyblok("https://www.indomascot.com/wp-json", {
  token: "my-api-key",
  space_id: my-space-id,
  content_types: [
    {
      name: "pages",
      new_content_type: "page",
      folder: "",
      schema_mapping: {
        title: "name",
        "_links.wp:featuredmedia.0": "content.preview_image",
        content: {
          field: "content.body_items",
          component: "rich-text",
          component_field: "content",
        },
      },
    },
  ],
});

wp2storyblok.migrate();

it return error

(node:2635) UnhandledPromiseRejectionWarning: Error: Request failed with status code 401
    at createError (/Volumes/HDD/gangsar/wordpress-importer/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/Volumes/HDD/gangsar/wordpress-importer/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/Volumes/HDD/gangsar/wordpress-importer/node_modules/axios/lib/adapters/http.js:260:11)
    at IncomingMessage.emit (events.js:387:35)
    at endReadableNT (internal/streams/readable.js:1317:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2635) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:2635) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
christianzoppi commented 3 years ago

@jamaluddinrumi I think you are using the access token of your space, but you need to use the OAuth token that you can get from your account here http://app.storyblok.com/#!/me/account. That is required for the management API which will take care of writing content into Storyblok. I will add some clear error messages in case an Unauthorized Error is thrown to make it clearer 🙂

jamaluddinrumi commented 3 years ago

here it is!

Screen Shot 2021-07-04 at 1 37 01 PM

let me try