Giter VIP home page Giter VIP logo

ctrip-apollo's Issues

Demo with SyntaxError: await is only valid in async function

I installed node v11.6.0 and tried to run the demo as below, but got the error message: SyntaxError: await is only valid in async function, which looks like something's missing...

Test Code:

const apollo = require('ctrip-apollo')

const app = apollo({
  host: 'http://106.12.25.204:8080',
  appId: '100004458'
})

// Get the default namespace
const namespace = app.namespace()
// Namespace is an EventEmitter of nodejs
.on('change', ({
  key,
  oldValue,
  newValue
}) => {
  // Updates new values to `process.env`
  process.env[key] = newValue
})

// - Fetch configurations for the first time
// - start update notification polling (by default)
await namespace.ready()

console.log(namespace.get('timeout'))

Error Message:

await namespace.ready()
^^^^^

SyntaxError: await is only valid in async function
    at new Script (vm.js:84:7)
    at createScript (vm.js:264:10)
    at Object.runInThisContext (vm.js:312:10)
    at Module._compile (internal/modules/cjs/loader.js:684:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
    at executeUserCode (internal/bootstrap/node.js:342:17)

The file format of the local cache file can be customized

The local cache file is configured. The generated local cache file is a file whose name is encrypted by base64 and has no file type. It is difficult to read. If you can customize or default .properties or .json, it is also a good choice.

Cann't get json config

No .json suffix added to the URL when get json namespace config.
But it's added when polling update.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.