Skip to main content

Function: isUniqueKeyConsumed

isUniqueKeyConsumed(error): boolean

True when the gateway answered that the write's uniqueKey was ALREADY CONSUMED: a CHAIN_DISPATCH_FAILED with HTTP status 409. The first attempt under that key may be applied (classifyFailure says unknown), so the app confirms the key it holds instead of submitting again or showing the server's text. It replaces error.code === 'CHAIN_DISPATCH_FAILED' && error.status === 409 and the regex on "already saved". Accepts an SDK error or a plain-object view (FailureView: code and status); every other value is false.

Parameters​

ParameterType
errorunknown

Returns​

boolean

Example​

if (isUniqueKeyConsumed(error)) return confirmAndShowResult(error.uniqueKey);