<commit_before>---
title: Methods
description: Documentation of Meteor's Method (Remote Procedure Call) API.
---

Methods are remote functions that Meteor clients can invoke.

{% apibox "Meteor.methods" %}

Example:

```js
Meteor.methods({
  foo: function (arg1, arg2) {
    check(arg1, String);
    check(arg2, [Number]);

    // .. do stuff ..

    if (/* you want to throw an error */) {
      throw new Meteor.Error("pants-not-found", "Can't find my pants");
    }

    return "some return value";
  },

  bar: function () {
    // .. do other stuff ..
    return "baz";
  }
});<commit_msg>Methods: Link at top to Meteor.call #115<commit_after>---
title: Methods
description: Documentation of Meteor's Method (Remote Procedure Call) API.
---

Methods are remote functions that Meteor clients can invoke with [`Meteor.call`](#Meteor-call).

{% apibox "Meteor.methods" %}

Example:

```js
Meteor.methods({
  foo: function (arg1, arg2) {
    check(arg1, String);
    check(arg2, [Number]);

    // .. do stuff ..

    if (/* you want to throw an error */) {
      throw new Meteor.Error("pants-not-found", "Can't find my pants");
    }

    return "some return value";
  },

  bar: function () {
    // .. do other stuff ..
    return "baz";
  }
});
{'fraction_non_alphanumeric': 0.1584, 'fraction_numerical': 0.0088, 'mean_word_length': 2.7680722891566263, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4294311', 'n_tokens_mistral': 440, 'n_tokens_neox': 399, 'n_words': 130}