files/en-us/web/api/lockmanager/query/index.md
{{APIRef("Web Locks API")}}{{securecontext_header}} {{AvailableInWorkers}}
The query() method of the {{domxref("LockManager")}} interface returns a {{jsxref('Promise')}} that resolves with an object containing information about held and pending locks.
query()
None.
A {{jsxref('Promise')}} that resolves with an object containing a snapshot of the {{domxref("LockManager")}} state. The object has the following properties:
held
LockInfo objects for held locks.pending
LockInfo objects for pending lock requests.The LockInfo object can have the following properties:
name
mode
"exclusive" or "shared".clientId
This method may return a promise rejected with a {{domxref("DOMException")}} of one of the following types:
InvalidStateError {{domxref("DOMException")}}
SecurityError {{domxref("DOMException")}}
const state = await navigator.locks.query();
for (const lock of state.held) {
console.log(`held lock: name ${lock.name}, mode ${lock.mode}`);
}
for (const request of state.pending) {
console.log(`requested lock: name ${request.name}, mode ${request.mode}`);
}
{{Specifications}}
{{Compat}}