Last active
September 2, 2021 03:46
-
-
Save MkDierz/9a0a47637a1095ac193ad79101f3e4bf to your computer and use it in GitHub Desktop.
basic axios example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request | |
from flask_restful import Resource, Api | |
app = Flask(__name__) | |
api = Api(app) | |
class data_api(Resource): | |
def post(self): | |
json_data = request.get_json() | |
print(json_data['data']) | |
print(json_data['select']) | |
#json_data berisi data dari post | |
api.add_resource(data_api, '/api/v1', endpoint='v1') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="text" id="input" > | |
<select id="select"> | |
<option value="str">String</option> | |
<option value="int">Interger</option> | |
<option value="bool">Boolean</option> | |
<option value="float">Decimal</option> | |
</select> | |
<button onclick="pushData()">submit</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var input = document.getElementById("input"); | |
var toggle = document.getElementById("toogle"); | |
function pushData() { | |
if (input.value) { | |
axios | |
.post("/api/v1", { | |
data: input.value, | |
select: select.value, | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment