标签: fetch

django-orm不区分大小写的顺序

我知道,我可以从DJango ORM进行不区分大小写的搜索.喜欢,

User.objects.filter(first_name__contains="jake")
User.objects.filter(first_name__contains="sulley")
User.objects.filter(first_name__icontains="Jake")
User.objects.filter(first_name__icontains="Sulley")
Run Code Online (Sandbox Code Playgroud)

而且,我可以把它们当作

user_list = User.objects.all().order_by("first_name")
# sequence: (Jake, Sulley, jake, sulley)
user_list = User.objects.all().order_by("-first_name") # for reverse
# sequence: (sulley, jake, Sulley, Jake)
Run Code Online (Sandbox Code Playgroud)

对于不区分大小写的提取有直接的方法吗?就像我想要一个序列一样

# desired sequence: jake, Jake, sulley, Sulley
Run Code Online (Sandbox Code Playgroud)

如果没有,那么建议一个最好的方法来做到这一点.提前致谢.

django case-insensitive django-orm fetch

33
推荐指数
3
解决办法
1万
查看次数

React-Native fetch,网络请求失败.不使用localhost

我有一个应用程序,我使用提取来验证用户.它在几天前工作,我没有改变任何东西.刚刚从0.27升级到0.28,没有提取不起作用.

我搜索了将近2天,我已经阅读了stackoverflow中的几乎所有问题.大多数用户试图从localhost获取内容,当他们将其更改为实际的IP地址时,他们就可以使用它.但我没有从localhost获取任何东西,也是我的代码以前工作.

这是我的代码:

fetch('http://somesite.com/app/connect', {
      method: 'POST',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
        'language':'en-US',
        'Authorization': 'Bearer ' + access_token,
      },
      body: JSON.stringify({
        uid: uid,
        refresh_token: refresh_token,
        token: access_token,
        device: device_id,
        device_name: device_name,
      })
    })
.then((response) => response.json())
.then((responseData) => {
    console.log(JSON.stringify(responseData.body))
})
.catch((err)=> {
  console.log('Some errors occured');
  console.log(err);
})
.done();
Run Code Online (Sandbox Code Playgroud)

我试图制作一些新项目,简单,只是使用一个简单的fetch示例来教程,它给出了同样的错误.我试图打开我的网站,我试图连接到它,通过模拟器中的浏览器,它的工作原理,但似乎通过我,应用程序无法连接到任何网站/ IP.它在chrome控制台中出现此错误:

TypeError: Network request failed
    at XMLHttpRequest.xhr.onerror (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:28193:8)
    at XMLHttpRequest.dispatchEvent (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:14591:15)
    at XMLHttpRequest.setReadyState (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:29573:6)
    at XMLHttpRequest.__didCompleteResponse (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:29431:6)
    at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:29506:52
    at RCTDeviceEventEmitter.emit (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:13428:23)
    at MessageQueue.__callFunction (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:11999:23)
    at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:11906:8
    at guard …
Run Code Online (Sandbox Code Playgroud)

javascript fetch ios reactjs react-native

30
推荐指数
1
解决办法
3万
查看次数

通过Fetch反应本机发布请求会导致网络请求失败

我遇到了以下错误.目前我正在使用React Native开发Android应用程序,因此我计划使用fetch为我做一个post请求.

fetch("https://XXreachable-domainXX.de/api/test", {
            method: "post",

            body: JSON.stringify({
                param: 'param',
                param1: 'param',

            })
        }
    )
        .then((response) = > response.json()
    )
    .
    then((responseData) = > {
        ToastAndroid.show(
        "Response Body -> " + JSON.stringify(responseData.message), ToastAndroid.SHORT
    )
})
    .
    catch((error) = > {
        console.warn(error);
})
    ;
Run Code Online (Sandbox Code Playgroud)

该应用程序现在抛出一个错误:

TypeError:网络请求失败

当我将代码更改为GET-Request它工作正常时,在浏览器中使用window.alert()作为返回它很酷,并且chrome扩展Postman正确地返回数据.

javascript android fetch react-native

29
推荐指数
4
解决办法
4万
查看次数

使用React Native中的Fetch获取查询字符串

我正在提出这样的请求:

fetch("https://api.parse.com/1/users", {
  method: "GET",
  headers: headers,   
  body: body
})
Run Code Online (Sandbox Code Playgroud)

如何传递查询字符串参数?我只是将它们添加到URL吗?我在文档中找不到一个例子.

fetch reactjs react-native

29
推荐指数
3
解决办法
5万
查看次数

从react组件进行REST调用

我正在尝试从react组件进行REST调用,并将返回的JSON数据呈现到DOM中

这是我的组件

import React from 'react';

export default class ItemLister extends React.Component {
    constructor() {
        super();
        this.state = { items: [] };
    }

    componentDidMount() {
        fetch(`http://api/call`) 
            .then(result=> {
                this.setState({items:result.json()});
            });
    }

    render() {        
        return(
           WHAT SHOULD THIS RETURN?
        );
    }
Run Code Online (Sandbox Code Playgroud)

为了在DOM中绑定返回的json?

rest json dom fetch reactjs

28
推荐指数
1
解决办法
6万
查看次数

fetch() 中的 Async/Await 如何处理错误

我的 React 应用程序中有条带异步代码,并尝试在我的代码中添加错误处理,但不知道如何处理它。我知道如何使用 .then() 但 async/await 对我来说是新的

已编辑

添加了 .catch() 我在响应选项卡的网络选项卡中出错。但我可以将它记录到控制台吗?

    submit = async () => {
    const { email, price, name, phone, city, street, country } = this.state;
    let { token } = await this.props.stripe
      .createToken({
        name,
        address_city: city,
        address_line1: street,
        address_country: country
      })
      .catch(err => {
        console.log(err.response.data);
      });

    const data = {
      token: token.id,
      email,
      price,
      name,
      phone,
      city,
      street,
      country
    };

    let response = await fetch("/charge/pay", {
      method: "POST",
      headers: {
        "Content-Type": "application/json"
      },
      body: JSON.stringify(data)
    }).catch(err …
Run Code Online (Sandbox Code Playgroud)

javascript asynchronous fetch reactjs

28
推荐指数
5
解决办法
4万
查看次数

FetchMode和FetchType之间的区别

指定lazy = "true"和使用有fetch = "select" or "join"什么区别 ?哪一个优于另一个?

关于jayendra

hibernate jpa fetch

27
推荐指数
2
解决办法
3万
查看次数

JPA 2条件获取路径导航

使用JPA 2 Criteria Join方法,我可以执行以下操作:

    //Join Example (default inner join)
    int age = 25;
    CriteriaBuilder cb = entityManager.getCriteriaBuilder();
    CriteriaQuery<Team> c = cb.createQuery(Team.class);
    Root<Team> t = c.from(Team.class);
    Join<Team, Player> p = t.join(Team_.players);
    c.select(t).where(cb.equal(p.get(Player_.age), age));
    TypedQuery<Team> q = entityManager.createQuery(c);
    List<Team> result = q.getResultList();
Run Code Online (Sandbox Code Playgroud)

我怎么能用fetch方法做同样的事情,我期望Fetch接口有get路径导航方法,但它没有:

    //Fetch Join Example

    int age = 25;
    CriteriaBuilder cb = entityManager.getCriteriaBuilder();
    CriteriaQuery<Team> cq = cb.createQuery(Team.class);
    Root<Team> t = cq.from(Team.class);
    Fetch<Team,Player> p = t.fetch(Team_.players);
    cq.where(cb.equal(p.get(Player_.age), age)); //This leads to compilation error there is no such method get in interface Fetch …
Run Code Online (Sandbox Code Playgroud)

java jpa fetch jpa-2.0

26
推荐指数
4
解决办法
3万
查看次数

有没有办法获取按PDO指定列的值分组的关联数组?

例如,让我们使用一些简单的数据集

+---------+------+------+------------+
| name    | age  | sex  | position   |
+---------+------+------+------------+
| Antony  |   34 | M    | programmer |
| Sally   |   30 | F    | manager    |
| Matthew |   28 | M    | designer   |
+---------+------+------+------------+
Run Code Online (Sandbox Code Playgroud)

我们想要得到的是以这种方式组织阵列

Array
(
  [Antony] => Array
    (
      [age] => 34
      [sex] => M
      [position] => programmer
    )

  [Sally] => Array
    (
      [age] => 30
      [sex] => F
      [position] => manager
    )

  [Matthew] => Array
    (
      [age] => 28
      [sex] => …
Run Code Online (Sandbox Code Playgroud)

php arrays pdo fetch

24
推荐指数
4
解决办法
2万
查看次数

如何使用node-fetch发送cookie?

我有nodejs应用程序处理用户的请求并接收我想代理到内部API服务的cookie.如何通过使用node-fetch来解决这个问题?

请不要提供superagent.

javascript fetch node.js

24
推荐指数
2
解决办法
1万
查看次数