@Kognise/

Repl.it API Example

Nodejs

An example on using my repl.it-api Node package.

fork
loading
Files
  • index.js
  • package-lock.json
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const ReplitClient = require('repl.it-api')
const client = new ReplitClient()

client.create().then(() => {
  console.log('Created')
  return client.connect()
}).then(() => {
  console.log('Connected')
  return client.writeMain('require(\'express\')().listen()')
}).then(() => {
  console.log('Wrote')
  return client.run({
    output: (output) => console.log('Output:', output.trim()),
    timedOut: () => console.log('Timed out!'),
    installStart: () => console.log('Install start'),
    installOutput: (output) => console.log('Install output:', output.trim()),
    installEnd: () => console.log('Install end'),
    listen: (port) => console.log('Listening on port', port)
  })
}).then((result) => {
  console.log('Result:', result)
  return client.close()
}).then(() => {
  console.log(client.getInfo())
})
node v10.16.0