问题描述
我们使用 React Native 开发了一个应用程序。 我将在下面留下应用程序的链接,不知道这是否被禁止。 我使用 axios 提取数据,它适用于所有 android 设备。但它不适用于小米手机。我找不到原因。
const api = "apiadress/deneme.PHP?lesid="+getLessonId;
axios.get(api).then((response)=>{
db.transaction((tx) => {
tx.executesql('UPDATE lessons SET downloaded=? WHERE id=?',['1',getLessonId]);
});
response.data.map((item) => {
db.transaction((tx) => {
tx.executesql('INSERT INTO questions (questionname,lessonname,answerbame,aoptionname,boptionname,coptionname,doptionname,eoptionname,lessonid,oldidq) VALUES (?,?,?)',[item.QuestionName,item.LessonName,item.AnswerName,item.AOption,item.BOption,item.coption,item.DOption,item.EOption,item.id,item.Id]);
});
});
console.log("Tüm sorular başarıyla kayıt edildi.");
});
代码的图像
解决方法
我不确定是什么问题,但我在 axios 上遇到了类似的问题(部署后服务器请求不起作用)
你应该考虑离开 axios 并尝试使用 fetch:
发布:
if message.content.startswith('!cuff'):
args = message.content.split(' ')
if len(args) == 2:
member: Member = discord.utils.find(lambda m: args[1] in m.name,message.guild.members)
if member:
role = get(message.server.roles,name='Cuff')
await client.add_roles('{}'.format(member.name))
获取:
fetch('http://mywebsite.com/endpoint/',{
method: "POST",headers: {
// Authorization: "Bearer " + Token,Accept: 'application/json','Content-Type': 'application/json'
},body: JSON.stringify({
// sending data userID username,password,etc
}),})
.then((response) => response.json())
.then((responseJson) => {
// Response will here
})
.catch((error) => {
alert(error);
});