edgekitjs - v0.0.51
    Preparing search index...

    Class Geo

    Entity that represents the geographical information of the client's request. This information is provided by Cloudflare Workers and is accessible through the request.cf object.

    import { geo } from "@edgefirst/core";
    geo().timezone; // "America/New_York"

    Hierarchy

    • Data<ObjectParser>
      • Geo
    Index

    Constructors

    • Parameters

      • request: Request

      Returns Geo

    Properties

    parser: ObjectParser
    request: Request

    Accessors

    Methods

    • Converts the Data object into a plain JSON representation, including all properties defined as getters in the subclass.

      The toJSON method dynamically identifies getter properties in the subclass and collects their values to construct a JSON object. This is particularly useful when you want to serialize the Data object for APIs, logging, or other use cases requiring JSON format.

      Returns {
          city: string;
          continent: ContinentCode;
          country: Iso3166Alpha2Code | "T1";
          isEurope: boolean;
          latitude: string;
          longitude: string;
          metroCode: string;
          postalCode: string;
          region: string;
          timezone: string;
      }

      A plain object representing the Data instance with all getter properties.

      class LoginData extends Data<FormParser> {
      get username() {
      return this.parser.getString("username");
      }
      get password() {
      return this.parser.getString("password");
      }
      }

      const loginData = new LoginData(new FormParser(formData));
      console.log(JSON.stringify(loginData.toJSON()));
      // Output: { "username": "johndoe", "password": "secret" }
    • Returns a string representation of an object.

      Returns string