AnsweredAssumed Answered

Load custom modules constructor error

Question asked by clement.laskar_onf on Mar 11, 2019
Latest reply on Mar 11, 2019 by rscheitlin



I was following this tutorial on Creating a Class and loading the module in the main JS with dojo. I followed it the best I could but I still get the error "SeatGeekSearch is not a constructor", and I cannot use my module.

I read the dojo doc on Creating Classes  and I saw this GeonetPost on loading custom modules but it didn't solved my problem. Here is my code : the module

define(['dojo/_base/declare', 'dojo/_base/lang', 'esri/request'],
          function(declare, land, esriRequest){
     declare(null, {
          distance: null,
          lastSearchResult: null,
          perPage: null,
          queryParams: null,
          seatGeekUrl: null,
          constructor: function(options){
               this.distance = options.distance || "20mi";
               this.perPage = options.perPage || 50;
               this.seatGeekUrl = "";
               this.returEvents = lang.hitch(this, this.returnEvents);
          searchByLoc: function(geopoint){
               let eventResponse;
               let queryParam = {
                         "lat": geopoint.y,
                         "long": geopoint.x,
                         "page": 1,
                         "per-page": this.perPage,
                         "range": this.distance
               eventsResponse = esriRequest({
                    "url": this.seatGeekUrl,
                    "callbackParamName": "callback",
                    "content": this.queryParams
               return eventsResponse.then(this.returnEvents, this.err)
          returnEvents: function(response){
          err: function(error){

The HTML file :

<DOCTYPE html>
          <META charset="utf-8">
          <title>Ma carte</title>
          <link rel="stylesheet" href="Arcgis_css.css">
                    height: 500px;
                    width: 500px;
          <h2>Ma carte</h2>
          <div id="map"></div>
          <script type="text/javascript">
          var dojoConfig = {
                      paths: { extras: location.pathname.replace(/\/[^/]+$/, "") + "extras" }

          <script src="js/JS-api-3.27.js"></script>
      require(["esri/map", "extras/SeatGeekSearch", "dojo/domReady!"], function(Map, SeatGeekSearch) {
        let map = new Map("map", {
          basemap: "national-geographic",  //For full list of pre-defined basemaps, navigate to
        let search = new SeatGeekSearch({
             distance: "20mi",
             perPage: 10
        map.on("click", function(e){
             var geographic = webMercatorUtils.webMercatorToGeographic(e.mapPoint);

I'm using 3.27 JS API on a Tomcat server.


Thanks a lot