ApiQuery.js

26 lines | 633 B Blame History Raw Download

import Log from './LogTools'


//Обертка для запросов к базе
//URL - 
//Methid : Get Post
//data: данные
export default function ApiQuery(url, method, data){
    Log("ApiQuery", "query to " + url);
    //let json = JSON.stringify(data);
    //debugger;
    return fetch(
        url,
            {
                method: method,
                headers: {
                    'Content-Type': 'application/json'
                },
                credentials: 'include',
                body: JSON.stringify(data)
            }
    ).then(function(response){
        return response.json();
    });
}