从Javascript获取Django中的HttpResponse

2024-04-20 14:07:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个django端点:

def endpoint(request):
    return HttpResponse("Hello!")

我在JS中这样称呼它:

fetch(baseUrl + "endpoint", {
      method: "POST",
    }).then(function(data) {
        // HOW DO I ACCESS THE "Hello!"?
    });

如何访问hello!在那一部分?谢谢


Tags: djangohelloreturnrequestdefjsfunctionfetch