axios发布有关flask和vuejs的多个数据

时间:2018-09-10 03:46:34

标签: flask vue.js axios

我要做的就是从网络用户输入中获取 s := make([]byte, n) // Fill s with something... for len(s) > 0 { b := s[0] // Get next byte s = s[1:] // Remove it from the slice // Deal with byte } context_answers并将其放在Flask上。 (对此我很陌生,很抱歉我对自己的工作含糊不清)

treatment_answers

我能够通过以下方式获得context_answers:

`context_answers = {"a":[1], "b":[2], "c":[3], "d":[4]}
treatment_answers = {"y":[10]}`    

和烧瓶

`methods: {
      handleSubmit() {    
        axios.post("/submit_survey", this.context_answers)
      }
    }`

但是如何在相同的axios post方法中获得`@app.route("/submit_survey", methods=["POST"]) def submit_survey(): context = request.get_json(force=True) context_df = pd.DataFrame.from_dict(context)` ?并在this.treatments_answers中?

我要创建一个具有以下内容的数据框:

submit_survey

非常感谢您!

1 个答案:

答案 0 :(得分:1)

如果您想过去很多参数,可以这样做:

methods: {
  handleSubmit() {    
    axios.post("/submit_survey", {context_answers: this.context_answers, 
                                                         treatments_answers: this.treatments_answers})
  .then( 
     (response) => { console.log(response) },
     (error) => { console.log(error) }
   )
  }
}

或尝试以下操作:

 methods: {
      handleSubmit() {    
        axios.post("/submit_survey", {context_answers: this.context_answers, 
                                                             treatments_answers: this.treatments_answers})
      .then(response => { 
         console.log(response)
      })
      .catch(error => {
         console.log(error)
      });
    }