Semantic-Org/Semantic-UI · error

API action used but no url was defined

Error message

API action used but no url was defined

What it means

This error is logged by the API module's get.templatedURL() function (api.js:804-824) when settings.action is specified (meaning the developer intends to use a named API endpoint from the settings.api map), but settings.api[action] is undefined. The module looks up the URL from the api configuration object by action name; if no entry exists for that action, it cannot determine the request URL and logs this error.

Source

Thrown at src/definitions/behaviors/api.js:1133

  onFailure   : function(response, $module) {},

  // server error
  onError     : function(errorMessage, $module) {},

  // request aborted
  onAbort     : function(errorMessage, $module) {},

  successTest : false,

  // errors
  error : {
    beforeSend        : 'The before send function has aborted the request',
    error             : 'There was an error with your request',
    exitConditions    : 'API Request Aborted. Exit conditions met',
    JSONParse         : 'JSON could not be parsed during error handling',
    legacyParameters  : 'You are using legacy API success callback names',
    method            : 'The method you called is not defined',
    missingAction     : 'API action used but no url was defined',
    missingSerialize  : 'jquery-serialize-object is required to add form data to an existing data object',
    missingURL        : 'No URL specified for api event',
    noReturnedValue   : 'The beforeSend callback must return a settings object, beforeSend ignored.',
    noStorage         : 'Caching responses locally requires session storage',
    parseError        : 'There was an error parsing your request',
    requiredParameter : 'Missing a required URL parameter: ',
    statusMessage     : 'Server gave an error: ',
    timeout           : 'Your request timed out'
  },

  regExp  : {
    required : /\{\$*[A-z0-9]+\}/g,
    optional : /\{\/\$*[A-z0-9]+\}/g,
  },

  className: {
    loading : 'loading',
    error   : 'error'

View on GitHub (pinned to 597843ab84)

Solutions

  1. Add the missing action to the api settings map: $.fn.api.settings.api['your action'] = '/your/url'.
  2. Ensure the action name in settings.action exactly matches the key in settings.api (including spaces and case).
  3. Alternatively, provide settings.url directly instead of relying on action-based URL lookup.

Example fix

// before
$('.user-btn').api({
  action: 'get user'
  // no api map entry for 'get user'
});

// after
$.fn.api.settings.api['get user'] = '/users/{$id}';
$('.user-btn').api({
  action: 'get user',
  urlData: { id: 42 }
});
Defensive patterns

Strategy: validation

Validate before calling

// Validate the action exists in the api map before using it
var actionName = 'get user';
if ($.fn.api.settings.api[actionName] !== undefined) {
  $('.el').api({ action: actionName });
} else {
  console.error('Action not defined in api map:', actionName);
  // Fallback to direct URL
  $('.el').api({ url: '/users/' + userId });
}

Type guard

// Check if an action is registered in the api map
function isActionDefined(action) {
  return $.fn.api && $.fn.api.settings && $.fn.api.settings.api && $.fn.api.settings.api[action] !== undefined;
}

Prevention

When it happens

Trigger: Configuring $('.el').api({ action: 'get user' }) without providing a corresponding entry in the api settings map ($.fn.api.settings.api['get user'] = '/users/{id}'). Also when the action name has a typo or mismatch in spacing/casing between the action property and the api map key.

Common situations: Defining API endpoints globally via $.fn.api.settings.api but forgetting an entry. Action names with inconsistent casing or extra spaces. Using data-api attributes that reference an action not defined in the api map. Migrating from URL-based to action-based configuration and missing entries.

Related errors


AI-assisted analysis of Semantic-Org/Semantic-UI@597843ab84 (2026-08-13). Data as JSON: /api/errors/abe40b8c27c99d08. Report an issue: GitHub.