Meteor React Tutorial Expected string, got object

Hi guys so I got to step 9 by following this tutorial https://www.meteor.com/tutorials/react/security-with-methods

So i’ve written all the methods with their checks however I get errors like Exception while invoking method 'tasks.remove' Error: Match error: Expected string, got object

Here are my written codes
This is the tasks.js

import { Meteor } from 'meteor/meteor'
import { Mongo } from 'meteor/mongo'
import { check } from 'meteor/check'

export const Tasks = new Mongo.Collection('tasks')

Meteor.methods({
  'tasks.insert' (text) {
    check(text, String)

    // Make sure the user is logged in before insterting a task
    if (!this.userId) {
      throw new Meteor.Error('not-authorized')
    }

    Tasks.insert({
      text,
      createdAt: new Date(),
      owner: this.userId,
      username: Meteor.users.findOne(this.userId).username
    })
  }, // tasks.insert
  'tasks.remove' (taskId) {
    check(taskId, String)

    Tasks.remove(taskId)
  },
  'tasks.setChecked' (taskId, setChecked) {
    check(taskId, String)
    check(setChecked, Boolean)

    Tasks.update(taskId, { $set: { checked: setChecked } })
  }
})

And this is the Task.jsx

import React, { Component, PropTypes } from 'react'
import { Meteor } from 'meteor/meteor'
// import { Tasks } from '../api/tasks.js'

// Task component - represents a single todo item
export default class Task extends Component {
toggleChecked () {
  // Set the checked value to the opposite of its current value
  Meteor.call('tasks.setChecked',this.props.task._id, !this.props.task.checked)
}

deleteThisTask () {
  Meteor.call('tasks.remove', this.props.task._id)
}
  render () {
    // Give tasks a different className when they are checked off,
    // so that we can style them nicely
    const taskClassName = this.props.task.checked ? 'checked' : ''
    return (
      <li className={taskClassName}>
        <button className="delete" onClick={this.deleteThisTask.bind(this)}>
          &times;
        </button>

        <input
          type="checkbox"
          readOnly
          checked={this.props.task.checked}
          onClick={this.toggleChecked.bind(this)}
        />

        <span className="text">
          <strong>{this.props.task.username}</strong>:{this.props.task.text}
        </span>
      </li>
    )
  }
}

Task.propTypes = {
  // This component gets the task to dipslay through a React prop.
  // We can use propTypes to indicate it is required
  task: PropTypes.object.isRequired
}

What’s the problem my written code seems to be identical with the tutorials code, why then do I get these errors? I got the same error for the update method.

Hey hayk,

I had the same problem. I don’t know why, but it seems the tasks you and I made towards the beginning of the tutorial did not have an _id string field. If you create a new task I think you will not have problems checking it off.

in imports/api/tasks.js replace this

check(taskId, String);

with this

check(taskId._str, String);