I'm new to both Flask and Vue.js and I'm a bit confused with everything.
So far, I've created a Flask app that sends data to Vue app, a table with filtering options. I now want to do the opposite, send filtered data from Vue and store them in a python object.
Here is my simplified code :
app.py
app = Flask(__name__)
app.config.from_object(__name__)
CORS(app, resources={r"/*":{'origins':"*"}})
# Sending data to http://localhost:5000/prices
@app.route("/prices", methods=["GET","POST"])
def all_prices():
dt_items = init_data()
json_items = prepare_data_for_front(dt_items)
return jsonify({"items" : json_items})
# Retrieve data from http://localhost:8085/saved
@app.route("/saved", methods=["GET", "POST"])
def all_select():
dt_saved = request.values
return jsonify(dt_saved)
app.run()
Script in PricesComponent.vue
import axios from 'axios';
export default {
...
methods: {
async postItems() {
await axios.post("http://localhost:5000/saved", JSON.stringify(this.filteredTable))
.then(response => {
console.log(response.data);
})
.catch(err=>{
console.log(err);
});
},
...
}
However, when I got to http://localhost:5000/saved, this is empty. There is no error. Looking at the console.log, I can see that response.data is an object and not a json, maybe the problem is that my flask app can't jsonify it.