Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-35146

[UDF] Javascript functions: trying to return undefined value

    XMLWordPrintable

Details

    • Untriaged
    • Centos 64-bit
    • Unknown

    Description

      I'm trying to return undefined value from js function:

       

      function f(a){
          let arr1={"a":1,"b":2}; 
          return arr1[a];
      } 
      alert(f("c"));
      

      Browser js console alerts "undefined", which is totally acceptable, since I don't have a key "c" in my map.

       

      Doing same thing using js inline function:

      curl -X GET http://192.168.10.10:35398/api/v1/functions
      {"name":"math","id":"f:39:45:b8:13:16:40:9b","code":"function add(a) { let arr1 = {\"a\":1, \"b\":2}; return arr1[a]; }"}
       
      

      and calling this function:

      execute FUNCTION javaScriptAdd("c")

      gives me this:

      [
       {
       "code": 10109,
       "msg": "Error executing function javaScriptAdd (math:add): invalid character 'u' looking for beginning of value - cause: invalid character 'u' looking for beginning of value"
       }
      ]

       

       

      Attachments

        For Gerrit Dashboard: MB-35146
        # Subject Branch Project Status CR V

        Activity

          People

            ajay.bhullar Ajay Bhullar
            evgeny.makarenko Evgeny Makarenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty