Here is my code,
import { Connection, programs } from "@metaplex/js";
const {
metaplex: { Store, AuctionManager },
metadata: { Metadata },
auction: { Auction },
vault: { Vault },
} = programs;
const publicKey = "Gz3vYbpsB2agTsAwedtvtTkQ1CG9vsioqLW3cNpvZ";
const connection = new Connection("devnet");
// Get the Metadata
const metadata = await Metadata.load(connection, publicKey);
const vault = await Vault.load(connection, publicKey);
Error
return new MetaplexError(ErrorCode.ERROR_INVALID_OWNER, 'Invalid owner');
It works in the case of Metadata but not working it's in the case of Vault or Auction
Here you are using one address that is publicKey for running two different types of functions which are completely Different. In this case vault pubkey refers to a different data and metadata pubkey refers to a different data. To explain it more Metadata.load(connection,pubkey) here pubkey is the metadataPubkey and refers to specific metadata whereas Vault refers to the Auction programs Manager's data. To deep dive, more into it you could go through the js repo code.
BTW Metaplex-foundation/js repo has been deprecated and soon going to be replaced by Metaplex-foundation/next-js which is in active development