未捕获的InvalidData:数据与未标记的枚举ArgsEnum的任何变体不匹配 [英] Uncaught InvalidData: data did not match any variant of untagged enum ArgsEnum

查看:318
本文介绍了未捕获的InvalidData:数据与未标记的枚举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 是Deno v0.42.0

  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 from const env = Deno.env() to const 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 with v0.42.0, since https://deno.land/x/postgres/mod.ts is pulling from master

Change db/database.js to import from https://deno.land/x/postgres@v0.3.11/mod.ts, since v0.3.11 is the correct version for Deno v0.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆