Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

When using node-fetch the response is not json #404

Open
Vilhelm-Ian opened this issue Sep 29, 2023 · 0 comments
Open

When using node-fetch the response is not json #404

Vilhelm-Ian opened this issue Sep 29, 2023 · 0 comments

Comments

@Vilhelm-Ian
Copy link

`const url = "http://127.0.0.1:8765";

async function invoke(action, version, params) {
try {
let res = await fetch(url, {
Method: "POST",
Body: JSON.stringify({
action,
version,
params,
}),
});
let data = await res.text();
return data;
} catch (e) {
console.log(e, "error");
}
}

invoke("deckNames", 6, {}).then((data) => console.log(data, "hello"));
`

The output is AnkiConnect v.6 hello
when I try res.json() it crashes and says it's not a json

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant