Within my for loop, I am retrieving the name
and id
of each credential in the following manner:
for (const cred of provider.credentials || []) {
const credId = cred.id
const credName = cred.name
const credValue = state[credName]
}
Yet, I encounter an error referenced in the title while establishing credValue
.
I suspect the issue arises when credName
is potentially null
. Even though I attempt to utilize the Non-null assertion operator as a solution, my attempts have not yielded success.
To clarify, the structure of the state object consistently resembles this:
state: {
cred1: 'value'
cred2: 'value'
}