zincsearch / sdk-nodejs-zincsearch

NodeJS SDK Client for ZincSearch

Home Page:https://docs.zincsearch.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SyntaxError: Cannot use import statement outside a module

cnn007 opened this issue · comments

commented

use sdk-nodejs-zincsearch/exmaples/index/exists/main.js

`/* Copyright 2022 Zinc Labs Inc. and Contributors
*

  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at
  • http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.
    */

var ZincSearchSDK = require('../../../src/index');

let defaultClient = ZincSearchSDK.ApiClient.instance;
// Configure HTTP basic authorization: basicAuth
let basicAuth = defaultClient.authentications['basicAuth'];
basicAuth.username = 'admin';
basicAuth.password = 'Complexpass#123';

let apiInstance = new ZincSearchSDK.Index();
let index = "index_example"; // String | Index
apiInstance.exists(index, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});`

errinfo:
sdk-nodejs-zincsearch/src/index.js:15
import ApiClient from './ApiClient';
^^^^^^

SyntaxError: Cannot use import statement outside a module

==================

We published sdk in npmjs, you should use that: https://www.npmjs.com/search?q=zincsearch

commented

Using this' https://www.npmjs.com/package/zincsearch-sdk' The expression+zincsearch-sdk demo reported an error.
code:

// import ZincSearchSDK from 'zincsearch-sdk'
// const { ZincSearchSDK } = require('zincsearch-sdk')
const ZincSearchSDK = require('zincsearch-sdk')

function test1() {

}

test1()

image

package.json

{
  "name": "zincsearch-demo",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "cookie-parser": "~1.4.4",
    "debug": "~2.6.9",
    "express": "~4.16.1",
    "http-errors": "~1.6.3",
    "morgan": "~1.9.1",
    "mysql2": "^3.2.3",
    "pug": "2.0.0-beta11",
    "sequelize": "^6.31.0",
    "undici": "^5.22.0",
    "zincsearch-sdk": "^0.3.3"
  }
}

Yes, it looks can't work with latest nodejs. i will try to fix it. Thanks.