DEV Community

Clever Cottonmouth
Clever Cottonmouth

Posted on

Resolve Angular - error TS2339: Property 'ncDisplay' does not exist on type 'Object'

res.body is coming from api response
if (res.status == 200) {
const data: any = res.body;
this.ncDisplay = data.ncDisplay;
}

This code is checking the status of the res object to see if it is equal to 200. If the status is 200, it is assumed that the response was successful and the data was returned in the body property of the res object. The body property is then assigned to a variable named data of type any. The code then accesses the ncDisplay property of the data object and assigns it to the ncDisplay property of the current object.

If you are still encountering the error "Property 'ncDisplay' does not exist on type 'Object'", make sure that the data object actually has a property named ncDisplay. You can also add type-checking to ensure that the data object has the required property before trying to access it.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more