-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
Hello, I have configured the service credential JSON, and import it under the project main file. The data read by this API is always empty. I do n’t know where I wrote the problem. What I want to achieve is through the new Google v1-client.projects.locations.registries.devices.list to get the API, but one encountered this problem, the following is my code:
const getClient = (res) => {
// the getClient method looks for the GCLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS
// environment variables if serviceAccountJson is not passed in
const authClient = google.auth.getClient({
keyFilename: 'riltmw025tool-2019-296a54b9be.json',
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});
const discoveryUrl = `${DISCOVERY_API}?version=${API_VERSION}`;
google.options({
auth: authClient,
});
try {
res.send(google.discoverAPI(discoveryUrl));
return google.discoverAPI(discoveryUrl);
} catch (err) {
console.error('Error during API discovery.', err);
}
};
//List all devices in the specified registry
const registry_list_Device = async (
client,
registryId,
projectId,
cloudRegion,
res
) => {
const parentName = `projects/${projectId}/locations/${cloudRegion}`;
const registryName = `${parentName}/registries/${registryId}`;
const request = {
parent: registryName,
};
res.send(client);
try {
const {data} = await client.projects.locations.registries.devices.list(
request
);
res.status(200).send(data);
console.log('Current devices in registry:', data['devices']);
} catch (err) {
res.status(402).send(err);
console.error('Could not list devices', err);
}
}
Metadata
Metadata
Assignees
Labels
type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.