Uncaught InvalidData: data did not match any variant of untagged enum ArgsEnum

人走茶凉 提交于 2020-06-27 10:53:05

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/61757437/uncaught-invaliddata-data-did-not-match-any-variant-of-untagged-enum-argsenum

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!