Skip to content

Item is not defined error #52

@christosmito

Description

@christosmito

I have made a pwa and twa app and released it on play store successfully. On play console I have created a subscription, in order the users to pay for monthly(etc) subscription, but in my app I get item is not defined error when I try to "fetch" it with the digitalgoods API.
This is my code

  let [srv, setSrv] = useState([]);
  let [supported, setSupported] = useState(false);
  let [digitalGoodsError, setDigitalGoodsError] = useState(false);
  useEffect(function () {
    async function getSubs() {
      if (window.getDigitalGoodsService === undefined) {
        // Digital Goods API is not supported in this context.
        return;
      }
      try {
        setSupported(true);
        const digitalGoodsService = await window.getDigitalGoodsService(
          "https://play.google.com/billing"
        );
        const details = await digitalGoodsService.getDetails(["weekly"]);
        let data = [];
        for (item of details) {
          data.push(item.price);
        }
        setSrv(data);
      } catch (error) {
        // Our preferred service provider is not available.
        // Use a normal web-based payment flow.
        console.error("Failed to get service:", error.message);
        setDigitalGoodsError("Failed to get service: " + error.message);
        return;
      }
    }
    getSubs();
  }, []);

And those are the subscriptions, which are active
image

Why do I get the item is not defined error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions