728x90
fetch_option = {
method: "POST",
headers: {
"Content-Type" : "application/json",
},
body : JSON.stringify(data),
};
fetch("url/", fetch_option).then(response => {return response.json()})
.then(response => {
// function to execute
})
.catch(function(err){
alert(err)
})
.finally(function(){
})
error -> catch
complete -> finally
// views.py
def AnyFunction(request):
data = json.load(request)
return JsonResponse({"data": data})
반응형