未捕获的InvalidData:数据与未标记的枚举ArgsEnum的任何变体不匹配 [英] Uncaught InvalidData: data did not match any variant of untagged enum ArgsEnum
问题描述
我对Deno充满热情,因此请尝试一下。在此处。
因此,当我尝试运行它时,出现此InvalidData错误:
错误:未捕获的InvalidData:数据与unwrapResponse($ deno $ / ops / dispatch_json.ts:43:11)的未标记枚举ArgsEnum
$现在,在我看来,尝试连接到数据库时出了点问题,但是我真的无法弄清楚是什么。
的任何变体不匹配在Object.sendAsync($ deno $ / ops / dispatch_json.ts:98:10)在异步Object.connect($ deno $ / net.ts:216:11)
在异步Connection.startup (https://deno.land/x/postgres/connection.ts:138:17)
在异步Client.connect(https://deno.land/x/postgres/client.ts:14:5 )
在异步Database.connect(file:///Users/svenhaaf/git/deno/logrocket_deno_api/db/database.js:17:5)
此InvalidData错误是什么意思?我应该如何解决呢?
仅供参考,我的deno --version打印:
deno 0.42.0
v8 8.2.308
打字稿3.8.3
代码:
我从 https://github.com/diogosouza/logrocket_deno_api,然后在config.js
中,将第1行从const env = Deno.env()
编辑为const env = Deno.env
,因为看起来Deno.env变成了对象而不是方法。解决方案该教程未使用版本化的URL,并且正在使用的
deno-postgres
版本与v0不兼容。 42.0
,因为https://deno.land/x/postgres/mod.ts
是从master提取的
更改
db / database.js
以从https导入: //deno.land/x/postgres@v0.3.11/mod.ts
,因为v0.3.11
是Denov0.42.0 $ c的正确版本$ c>
import {客户端}来自 https://deno.land/x/postgres@v0.3.11/mod .ts;
如果您不希望代码在以下情况下停止工作,请记住始终使用URL中的版本发行了新的Deno或软件包版本。
I'm enthusiastic about Deno so I'm giving it a try. Found a tutorial on building a REST API here.
So, when I'm trying to run it, I get this InvalidData error:
error: Uncaught InvalidData: data did not match any variant of untagged enum ArgsEnum at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11) at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10) at async Object.connect ($deno$/net.ts:216:11) at async Connection.startup (https://deno.land/x/postgres/connection.ts:138:17) at async Client.connect (https://deno.land/x/postgres/client.ts:14:5) at async Database.connect (file:///Users/svenhaaf/git/deno/logrocket_deno_api/db/database.js:17:5)
Now, it looks to me that something is wrong when trying to connect to the database, but I can't really figure out what.
What does this InvalidData error mean? How should I fix this?
FYI my deno --version prints:
deno 0.42.0 v8 8.2.308 typescript 3.8.3
Code: I cloned the repo from https://github.com/diogosouza/logrocket_deno_api, and in
config.js
, I edited line 1 fromconst env = Deno.env()
toconst env = Deno.env
, since it looks like Deno.env became an object instead of a method.解决方案The tutorial is not using versioned URLs, and
deno-postgres
version that is being used is not compatible withv0.42.0
, sincehttps://deno.land/x/postgres/mod.ts
is pulling frommaster
Change
db/database.js
to import fromhttps://deno.land/x/postgres@v0.3.11/mod.ts
, sincev0.3.11
is the correct version for Denov0.42.0
import { Client } from "https://deno.land/x/postgres@v0.3.11/mod.ts";
Remember to always use the version in the URL if you don't want the code to stop working when a new Deno or package version is released.
这篇关于未捕获的InvalidData:数据与未标记的枚举ArgsEnum的任何变体不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!