Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function setEndpoint(projectId) {
// [START automl_set_endpoint]
const automl = require('@google-cloud/automl').v1beta1;
// You must first create a dataset, using the `eu` endpoint, before you can
// call other operations such as: list, get, import, delete, etc.
const clientOptions = {apiEndpoint: 'eu-automl.googleapis.com'};
// Instantiates a client
const client = new automl.AutoMlClient(clientOptions);
// A resource that represents Google Cloud Platform location.
const projectLocation = client.locationPath(projectId, 'eu');
// [END automl_set_endpoint]
// Grabs the list of datasets in a given project location.
// Note: create a dataset in `eu` before calling `listDatasets`.
const responses = await client.listDatasets({parent: projectLocation});
// Prints out each dataset.
const datasets = responses[0];
datasets.forEach(dataset => {
console.log(dataset);
});
}