1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { fetch } from "https://esm.town/v/std/fetch";
import process from "node:process";
export let getLocationEntities = async (text) => {
const URL = `https://language.googleapis.com/v1beta2/documents:analyzeEntities?key=${process.env.googleAPIKey}`;
const bodyText = {
document: {
content: text,
boilerplateHandling: "BOILERPLATE_HANDLING_UNSPECIFIED",
language: "en",
type: "PLAIN_TEXT",
},
};
let response = await fetch(URL, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify(bodyText),
});
return response.json();
};