【发布时间】:2021-11-09 23:48:01
【问题描述】:
连接到外部 API 时,我的 React Native 应用程序出现 CORS 访问错误。
async componentDidMount() {
// POST request using fetch with async/await
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: JSON.stringify({ type:'accountLookup',storeId:STORE_ID, storeKey:STORE_KEY, memberId:'471324' })
};
const response = await fetch('http://frequent5.revlogical.com/wsMobile', requestOptions);
const data = await response.json();
this.setState({ data: data });
【问题讨论】:
标签: reactjs react-native cors