mirror of
https://github.com/strapi/strapi.git
synced 2025-11-10 07:10:11 +00:00
Fix CORS issue
This commit is contained in:
parent
ceac222cb6
commit
4875649bc7
File diff suppressed because one or more lines are too long
@ -11,7 +11,6 @@ function* getVideos() {
|
|||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
mode: 'no-cors',
|
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import auth from 'utils/auth';
|
|||||||
* @return {object} The parsed JSON from the request
|
* @return {object} The parsed JSON from the request
|
||||||
*/
|
*/
|
||||||
function parseJSON(response) {
|
function parseJSON(response) {
|
||||||
// return response;
|
|
||||||
return response.json ? response.json() : response;
|
return response.json ? response.json() : response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +20,7 @@ function parseJSON(response) {
|
|||||||
* @return {object|undefined} Returns either the response, or throws an error
|
* @return {object|undefined} Returns either the response, or throws an error
|
||||||
*/
|
*/
|
||||||
function checkStatus(response, checkToken = true) {
|
function checkStatus(response, checkToken = true) {
|
||||||
if (response.status >= 200 && response.status < 300) {
|
if ((response.status >= 200 && response.status < 300) || response.status === 0) {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +154,7 @@ export default function request(...args) {
|
|||||||
if (options && options.body && stringify) {
|
if (options && options.body && stringify) {
|
||||||
options.body = JSON.stringify(options.body);
|
options.body = JSON.stringify(options.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fetch(url, options)
|
return fetch(url, options)
|
||||||
.then(checkStatus)
|
.then(checkStatus)
|
||||||
.then(parseJSON)
|
.then(parseJSON)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user