Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit f945c899 authored by peter_rabbit's avatar peter_rabbit
Browse files

fix fetch json

parent 4db61938
No related branches found
No related tags found
No related merge requests found
......@@ -166,7 +166,9 @@ module.exports = {
function fetchjson(url) {
return new Promise((resolve, reject) => {
fetch(url, { mode: "no-cors" })
const headers = new Headers();
headers.append("Accept", "application/json");
fetch(url, { mode: "no-cors", headers })
.then(r => r.json())
.then(r => resolve(r))
.catch(e => reject(e));
......@@ -174,8 +176,10 @@ function fetchjson(url) {
}
function fetchtext(url) {
const headers = new Headers();
headers.append("Accept", "text/html");
return new Promise((resolve, reject) => {
fetch(url, { mode: "no-cors" })
fetch(url, { mode: "no-cors", headers })
.then(r => r.text())
.then(r => resolve(r))
.catch(e => reject(e));
......
......@@ -435,7 +435,9 @@ module.exports = {
function fetchjson(url) {
return new Promise((resolve, reject) => {
fetch(url, { mode: "no-cors" })
const headers = new Headers();
headers.append("Accept", "application/json");
fetch(url, { mode: "no-cors", headers })
.then(r => r.json())
.then(r => resolve(r))
.catch(e => reject(e));
......@@ -443,8 +445,10 @@ function fetchjson(url) {
}
function fetchtext(url) {
const headers = new Headers();
headers.append("Accept", "text/html");
return new Promise((resolve, reject) => {
fetch(url, { mode: "no-cors" })
fetch(url, { mode: "no-cors", headers })
.then(r => r.text())
.then(r => resolve(r))
.catch(e => reject(e));
......
......@@ -2,7 +2,9 @@
function fetchjson(url) {
return new Promise((resolve, reject) => {
fetch(url, { mode: "no-cors" })
const headers = new Headers();
headers.append("Accept", "application/json");
fetch(url, { mode: "no-cors", headers })
.then(r => r.json())
.then(r => resolve(r))
.catch(e => reject(e));
......@@ -10,8 +12,10 @@ function fetchjson(url) {
}
function fetchtext(url) {
const headers = new Headers();
headers.append("Accept", "text/html");
return new Promise((resolve, reject) => {
fetch(url, { mode: "no-cors" })
fetch(url, { mode: "no-cors", headers })
.then(r => r.text())
.then(r => resolve(r))
.catch(e => reject(e));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment