fetch GET method. Request with GET/HEAD method cannot have body

Данные с сервера могут быть обработаны только GET запросом. Ajax не могу использовать, т.к. с политикой проблемы.

let sentData = function () { 

    var requestOptions = {
        method: 'GET',
        headers: {
            'Authentication': 'Token ' +  encodeAuth,
            'Content-Type':   "application/json",
            'Access-Control-Allow-Origin': 'LINK'
        },
        body: 1,  
    };

    fetch("LINK", 
        requestOptions) 
    .then(response =>console.log(response))
    .then(result => {
        console.log(result) 
    })
    .catch(error => console.log('error', error));
}
sentData()

Получаю ответ file.html:38 error TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.

Если написать POST, всё срабатывает, но данные в result = undefined

Где я допустил ошибку?


Ответы (0 шт):