postman
で応答を得ることができます。しかし、axios
に入ることができません。応答としてhtmlを取得します。何が問題でしょうか?アキシャルを使用してヘッダを取得する要求を送信できません
import axios from 'react-native-axios';
var config = {
headers: {
'Content-Type': 'Application/Json',
'JsonStub-User-Key': '__USER__KEY',
'JsonStub-Project-Key': '__PROJECT__KEY'
}
};
export async function menuListByCategories() {
// simulate an asynchronous operation
const url = "http://jsonstub.com/burgers";
axios.get(url, {config})
.then((response) = > {
console.log(response.data);
})
.
catch ((error) = > {
console.log("axios error:", error);
});
}
更新:check the response of this code
404や500などのエラー応答はありますか? – IzumiSy
@IzumiSyは200として応答します。 html形式で提供しています。 jsonにはありません – Balasubramanian
しかし、アキシャスで200の反応を得ることはできませんよね?それでは、どうしますか? – IzumiSy