diff --git a/packages/gapic-node-templating/src/get-bootstrap-template-vars.ts b/packages/gapic-node-templating/src/get-bootstrap-template-vars.ts index 5d532a34068..2743eaf274d 100644 --- a/packages/gapic-node-templating/src/get-bootstrap-template-vars.ts +++ b/packages/gapic-node-templating/src/get-bootstrap-template-vars.ts @@ -115,9 +115,11 @@ export async function compileVars( export function getServiceName(serviceConfig: ServiceConfig) { let serviceName = ''; - for (const api of serviceConfig?.apis) { - if (api.name.endsWith('Service')) { - serviceName = api.name.split('.')[api.name.split('.').length - 1]; + if (serviceConfig?.apis) { + for (const api of serviceConfig.apis) { + if (api.name.endsWith('Service')) { + serviceName = api.name.split('.')[api.name.split('.').length - 1]; + } } }