Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 483
Sventies Avatar asked May 12 '20 16:05

Sventies


1 Answers

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/[email protected]/mod.ts, since v0.3.11 is the correct version for Deno v0.42.0

import { Client } from "https://deno.land/x/[email protected]/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.

like image 148
Marcos Casagrande Avatar answered Oct 16 '22 11:10

Marcos Casagrande