【发布时间】:2020-07-04 09:22:32
【问题描述】:
我已将 zf3/laminas API 配置为获取 JSON 数据。它在 IOS 或 web 模拟器中运行良好,但在 android 中无法运行。
它抛出:
Object {
"detail": "Unable to resolve Accept header to a representation",
"status": 406,
"title": "Not Acceptable",
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
}
这是标头zf3发送反应:
Headers {
"map": Object {
"access-control-allow-headers": "Authorization, Origin, X-Requested-With, Content-Type:application/json, Accept:*",
"access-control-allow-methods": "PUT, GET, POST, PATCH, DELETE, OPTIONS",
"access-control-allow-origin": "http://localhost:4200",
"cache-control": "public, max-age=0",
"cf-cache-status": "DYNAMIC",
"cf-ray": "5ad7bbb47f45db28-KIX",
"cf-request-id": "03bab3a4ce0000db282798b200000001",
"connection": "keep-alive",
"content-type": "application/problem+json",
"date": "Sat, 04 Jul 2020 09:13:57 GMT",
"server": "cloudflare",
"vary": "Accept-Encoding,User-Agent",
"x-powered-by": "PHP/7.2.30",
},
}
我的反应功能:
async componentDidMount() {
try {
const call = await fetch(API_URL_INIT, [{'accept':'application/json', 'content-type':'application/json'}]);
console.warn(call.headers);//.get('Access-Control-Allow-Origin'));
const resp = await call.json();
} catch(err) {
this.setState({error: true});
console.log("Error fetching data-- ---------", err);
}
}
我做错了什么?
【问题讨论】:
标签: react-native zend-framework3 laminas-api-tools