Отправляю запрос так:
function send() {
var uri = 'http://127.0.0.1:5000/todo/api/v1.0/tasks';
var method = 'GET'
var request = {
url: uri,
type: method,
contentType: "application/json",
accepts: "application/json",
cache: false,
dataType: 'json',
};
return $.ajax(request);
};
в логе прилетает вот такая каша (лог ниже), typeof говорит, что это объект, не могу понять
как мне извлечь responseText ?
{readyState: 1, getResponseHeader: ƒ, getAllResponseHeaders: ƒ, setRequestHeader: ƒ, overrideMimeType: ƒ, …}abort: ƒ ( statusText )always: ƒ ()complete: ƒ ()done: ƒ ()error: ƒ ()fail: ƒ ()getAllResponseHeaders: ƒ ()getResponseHeader: ƒ ( key )overrideMimeType: ƒ ( type )pipe: ƒ ( /* fnDone, fnFail, fnProgress */ )progress: ƒ ()promise: ƒ ( obj )readyState: 4responseText: "{↵ "tasks": [↵ {↵ "title": "Buy groceries",↵ "description": "Milk, Cheese, Pizza, Fruit, Tylenol",↵ "done": false,↵ "uri": "/todo/api/v1.0/tasks/1"↵ },↵ {↵ "title": "Learn Python",↵ "description": "Need to find a good Python tutorial on the web",↵ "done": false,↵ "uri": "/todo/api/v1.0/tasks/2"↵ }↵ ]↵}↵"setRequestHeader: ƒ ( name, value )state: ƒ ()status: 200statusCode: ƒ ( map )statusText: "OK"success: ƒ ()then: ƒ ( /* fnDone, fnFail, fnProgress */ )__proto__: Object
Если запрос отправить вручную в браузере
127.0.0.1:5000/todo/api/v1.0/tasks, то возвращается нормальный json:
{
"tasks": [
{
"title": "Buy groceries",
"description": "Milk, Cheese, Pizza, Fruit, Tylenol",
"done": false,
"uri": "/todo/api/v1.0/tasks/1"
},
{
"title": "Learn Python",
"description": "Need to find a good Python tutorial on the web",
"done": false,
"uri": "/todo/api/v1.0/tasks/2"
}
]
}