deta / cloud-docs

old docs. visit space docs instead:

Home Page:https://github.com/deta/space-docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error running Cron and HTTP code snippets

nikahmadz opened this issue · comments

Hi, I want to know, does this piece of code in the tutorial works? because I got error.
[1]: https://docs.deta.sh/docs/micros/cron#cron-and-http

const { App } = require('deta');
const express = require('express');

const app = App(express());

app.get('/', async(req, res) => {
    res.send('Hello Deta, I am running with HTTP');
});

app.lib.cron(event => {
    return 'Hello Deta, I am a cron job';
});

module.exports = app;

when I run node index.js
I got this error

const app = App(express());
            ^

TypeError: App is not a function
    at Object.<anonymous> (.\index.js:4:13)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

I'm running deta v1.3.0-beta x86_64-windows

the code in these examples only work when deployed on a Micro, sorry for the confusion, we should make it clear in the docs.