Reading an ICRC-1 name in JS

Actor creates ok but I cannot call functions on it and get a result.

const token_name = await actor.icrc1_name();
console.log(token_name);

I never see this log^

import { idlFactory } from "../../declarations/token/token.did.js";

document.querySelector("form").addEventListener("submit", async (e) => {
  e.preventDefault();
  const button = e.target.querySelector("button");

  const name = document.getElementById("name").value.toString();

  button.setAttribute("disabled", true);

  const token = "avqkn-guaaa-aaaaa-qaaea-cai"
  const whitelist = [token];
  await window.ic.plug.requestConnect({
          whitelist,
        });
        var p = await window.ic.plug.agent.getPrincipal();
        //setAccAdd(p.toString());
        console.log(p.toString());
        const a = {
          owner: p,
          subaccount: [],
        }
        const actor = await window.ic.plug.createActor({
          canisterId: token,
          interfaceFactory: idlFactory,
        });
        console.log(actor);
        console.log("asking for name")
        const token_name = await actor.icrc1_name();
        console.log(token_name);
        try {
        const b = await actor.icrc1_balance_of(a);
      } catch(e) {
        console.log(e);
      }
        console.log(b);
        const precision = 100000000n;
        const bal = Number(b * 100000000n / precision) / 100000000;
        console.log(bal);

  // Interact with foo actor, calling the greet method
//  const greeting = await token_lobby_backend.greet(name);

  //button.removeAttribute("disabled");

  //document.getElementById("greeting").innerText = greeting;

  return false;
});

Most ICRC-1 query methods don’t require an identity, this includes the name method. So I would recommend to just create a new HttpAgent without any identity, create an actor with that agent and make those calls.

For calls where you for example transfer funds you can try to use the createActor method from Plug.

Shouldn’t it still work with an identity?

I tried with the identity connect pulled out, same error.