I want insert simple text to the mongo database with react but, when i submit the form print this line in console:
insert failed: Method '/resolutions/insert' not found
Tips: autopublish
and insecure
already installed. and i have react 15 and meteor 1.3.1
Here is my code:
import { Meteor } from 'meteor/meteor'; import React from 'react'; import ReactDOM from 'react-dom'; Resolutions = new Mongo.Collection('resolutions'); Resolutions.allow({ insert: function(userId,doc) { return true; } }); // import './index.html'; export default class App extends React.Component { AddResolution(event) { let text = this.refs.resolutions.value.trim(); // Insert into database Resolutions.insert({ text: text, complete: false, createAt: new Date() }); this.refs.resolutions.value = ""; event.preventDefault(); } render() { return ( <div> <h1>My swsolutions</h1> <form className="new-resolution" onSubmit={this.AddResolution.bind(this)}> <input type="text" ref="resolutions" placeholder="Finish React Meteor"/> </form> </div> ); } }
Just ran into this problem an hour ago. You're going to want to do 'Resolutions._collection.insert' instead of just 'Resolutions.insert'.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.