2017-07-14 7 views
0

には、POSTメソッドを使用する際にFirebaseでカスタムIDを設定する方法がありますか?以下のようなもの:Firebase POSTのカスタムID

{ 
    "users": { 
    "user_one": { 
     "username": "jdoe", 
     "password": "123" 
    } 
    } 
} 

私はVue.jsプロジェクトに取り組んなど一部の学生とその親を保存しようとしている:

let padre = { 
    nombre: this.padre.nombre, 
    apellido: this.padre.apellido, 
    cedula: this.padre.cedula, 
    nacionalidad: this.padre.nacionalidad, 
    estado_civil: this.padre.estado_civil, 
    instruccion: this.padre.instruccion, 
    profesion: this.padre.profesion, 
    trabaja: this.padre.trabaja, 
    l_trabajo: this.padre.l_trabajo, 
    d_trabajo: this.padre.d_trabajo, 
    tlf_trabajo: this.padre.tlf_trabajo, 
    tlf_habitacion: this.padre.tlf_habitacion, 
    tlf_movil: this.padre.tlf_movil 
} 

    axios.post('https://projectname.firebaseio.com/padres.json', padre) 
    .then(function (response) { 
     console.log(response); 
    }) 
    .catch(function (error) { 
     console.log(error); 
    }); 

答えて

0

あり確認されています。 HTTP PUTメソッドを使用して、パス全体を指定するだけです。あなたのライブラリによっては、次のような単純なものもあります:

axios.post('https://projectname.firebaseio.com/padres/user_one.json', padre) 

詳細については、Firebase REST API documentation on the PUT commandを参照してください。

+0

ありがとうございました!これは完全に機能しました –