how to send data use http get method
See original GitHub issueI want to send params and data use http get methods
I want get http params and data at backend. Example Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue get send data demo</title>
</head>
<body>
<div id="app">
this is app info: {{info}}
</div>
<script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
<script>
data = {"name": "danerlt", "age": 23}
index = 1
count = 15
url = `http://localhost:5000/get_body?index=${index}&count=${count}`
console.log(url)
console.log(data)
new Vue({
el: '#app',
data () {
return {
info: null
}
},
mounted () {
axios.get(url, body=data).then(response => (this.info = response))
}
})
</script>
</body>
</html>
my backend code use python flask
# -*- coding: utf-8 -*-
import json
from flask import Flask, request, jsonify
from flask_cors import CORS
app = Flask(__name__)
CORS(app, resources=r'/*')
@app.route('/get_body', methods=["GET"])
def get_http_body():
args = request.args
print('get_http_body args: %s' % [args])
try:
body = request.data.decode()
print('get_http_body body: %s' % body)
# data = json.loads(body)
except Exception as e:
print(e)
return jsonify(status='error', msg=str(e))
else:
return jsonify(status='ok', data=body)
Environment:
- Axios Version 0.18.0
- OS: Windows 10
- Browser : Chrome
Additional context/Screenshots In my python code, the http data is empty string, When I use poseman like this: It return the right result, How can I resove this probleam?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
How to send data in request body with a GET when using ...
1.GET use of Query string as. {{url}}admin/recordings/some_id ; here the some_id is mendatory parameter to send and can be used and req.params.some_id at...
Read more >HTTP Methods GET vs POST - W3Schools
The two most common HTTP methods are: GET and POST. The GET Method. GET is used to request data from a specified resource....
Read more >How do I send an HTTP GET request? - ReqBin
The GET request method is used to fetch data from the server. We cannot send data in the body of an HTTP GET...
Read more >GET - HTTP - MDN Web Docs
The HTTP GET method requests a representation of the specified resource. Requests using GET should only be used to request data (they ...
Read more >HTTP Request Methods – Get vs Put vs Post Explained with ...
PUT requests are idempotent, meaning that executing the same PUT request will always produce the same result. On the other hand, a POST...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try
axios.get(url, { params: data }
instead of above usage.@danerlt 通过一些网上的查找,准确的描述见更新后的https://github.com/axios/axios/issues/2598#issuecomment-563965172.