if (!('eRegistratorLib' in window)) {window['eRegistratorLib'] = {};} window.eRegistratorLib.scrAstral = { url: 'https://www.srv4you.ru/api/v1/astral/ajax/ajax.php', go: async function(formData, callback, callbackError){ let url = this.url; try { const res = await fetch(url, { method: 'POST', body: formData, cache: 'no-cache', } ); const contentType = res.headers.get('content-type'); if (!contentType || !contentType.includes('application/json')) { throw new TypeError("Ошибка JSON!"); } if (!res.ok) { throw new TypeError("Запрос завершился с ошибкой!"); } let data = await res.json(); console.log(data); if ((callback) && (typeof callback == 'function')){ callback(data); } } catch (error) { console.log('Ошибка:' + error); if ((callbackError) && (typeof callbackError == 'function')){ callbackError({ "ERRORS": [error], "STATUS": 400 }); } } }, };