Forráskód Böngészése

updated parse json in js fetch

Piotr Labudda 8 éve
szülő
commit
cffb724cc7
1 módosított fájl, 10 hozzáadás és 1 törlés
  1. 10 1
      SE/se-lib/TableAjax.php

+ 10 - 1
SE/se-lib/TableAjax.php

@@ -2934,7 +2934,16 @@ class TableAjax extends ViewAjax {
 								}).join(','),
 								}).join(','),
 							})
 							})
 						}).then(function (response) {
 						}).then(function (response) {
-							return response.json()
+							return response.text()
+						}).then(function (responseText) {
+							try {
+								// json = response.json() // BUG: error trafia do catch promisów, zamiast aktualnego bloku
+								// -- obiekt response pewnie jest powiązany z Promisem z fetch
+								// -- response.json() zwraca Promise tak samo jak response.text()
+								return JSON.parse(responseText)
+							} catch (e) {
+								throw responseText
+							}
 						}).then(function (result) {
 						}).then(function (result) {
 							if ('success' == result.type) {
 							if ('success' == result.type) {
 								p5UI__notifyAjaxCallback(result)
 								p5UI__notifyAjaxCallback(result)