no-cors mode test

This commit is contained in:
kurpfish 2021-08-05 16:52:18 +03:00
parent ffd679a0a9
commit 1d5bdff96c

View File

@ -1,6 +1,8 @@
export const fetchProfile = async (link, index) => { export const fetchProfile = async (link, index) => {
try { try {
const response = await fetch(`${link}${index}`, { const response = await fetch(`${link}${index}`, {
method: 'GET',
mode: 'no-cors',
headers: { headers: {
'Access-Control-Request-Headers': 'authorization', 'Access-Control-Request-Headers': 'authorization',
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`, 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
@ -16,6 +18,8 @@ export const fetchProfile = async (link, index) => {
export const fetchSkills = async (link) => { export const fetchSkills = async (link) => {
try { try {
const response = await fetch(link, { const response = await fetch(link, {
method: 'GET',
mode: 'no-cors',
headers: { headers: {
'Access-Control-Request-Headers': 'authorization', 'Access-Control-Request-Headers': 'authorization',
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`, 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
@ -32,8 +36,10 @@ export const fetchItemsForId = async (link, id) => {
console.log(`Bearer ${localStorage.getItem('auth_token')}`); console.log(`Bearer ${localStorage.getItem('auth_token')}`);
try { try {
const response = await fetch(`${link}${id}`, { const response = await fetch(`${link}${id}`, {
method: 'GET',
mode: 'no-cors',
headers: { headers: {
// 'Access-Control-Request-Headers': 'authorization', 'Access-Control-Request-Headers': 'authorization',
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`, 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
'Origin': `${process.env.REACT_APP_BASE_URL}`, 'Origin': `${process.env.REACT_APP_BASE_URL}`,
} }
@ -48,6 +54,7 @@ export const fetchForm = async (link, info) => {
try { try {
const response = await fetch(link, { const response = await fetch(link, {
method: 'POST', method: 'POST',
mode: 'no-cors',
headers: { headers: {
'Access-Control-Request-Headers': 'authorization', 'Access-Control-Request-Headers': 'authorization',
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`, 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,