I have successfully stored documents on Cosmos, but I am encountering an issue when trying to retrieve them using the "read" method.
this.cosmos = new CosmosClient({
endpoint: ''
key: ''
});
this.partitionKey = '/id'
this.container = this.cosmos.database('test').container('test');
type Data = {
value: string;
} & ItemDefinition;
// read operation
const { resource } = await this.container.item(key, this.partitionKey).read<Data>();
console.log('>>>', JSON.stringify(resource));
This code snippet prints >>> undefined
Can someone help me troubleshoot what might be wrong with my approach?
UPDATE: After further investigation, the statusCode returned is 404, even though the object exists in the database. What could be causing this discrepancy?