这是我的代码,我尝试从API得到响应,在控制台或API测试中我得到响应,但在Gatsby中返回CROS错误
import React from 'react'
import { getUser } from './services/auth'
const axios = require('axios');
class Main extends React.Component {
state = { loading: false, json: null }
componentDidMount (){
const fetchTurnos = () => axios({method:'GET',url:'https://zauru.herokuapp.com/sales/reports/sold_active_items_with_clients.json?point_of_sale_id=2505',headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-User-Email': 'x@xxxxx.com',
'X-User-Token':'XXXXXXXXXXX',
}});
const turnos = fetchTurnos();
console.log(turnos);
}
此标头发送浏览器
Host: zauru.herokuapp.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate, br
Access-Control-Request-Method: GET
Access-Control-Request-Headers: x-user-email,x-user-token
Referer: http://localhost:8000/app/