Use optional chaining operator (?.) to avoid TypeError: Cannot read property 'replicas' of undefined

Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com>
This commit is contained in:
Hung-Han (Henry) Chen authored and Hung-Han (Henry) Chen committed 2020-11-03 18:26:21 +08:00
1 parent 2b2499107f
commit 26438715f6
1 file changed
+1 -1
+1 -1
View File
@@ -10,7 +10,7 @@ export class DeploymentApi extends KubeApi<Deployment> {
getReplicas(params: { namespace: string; name: string }): Promise<number> {
return this.request
.get(this.getScaleApiUrl(params))
.then(({ status }: any) => status.replicas)
.then(({ status }: any) => status?.replicas)
}
scale(params: { namespace: string; name: string }, replicas: number) {