Fetch 结果显示相反的结果

Fetch 结果显示相反的结果,fetch,expo,Fetch,Expo,我和我的团队正在为Expo开发fetch方法,它看起来像这样 export function getCalendarEvents() { return fetch('http://50520dbf.ngrok.io/api/v1/events/date/') .then((response) => response.json()) .then((responseJson) => { this.setState({ isLoaded:

我和我的团队正在为Expo开发fetch方法,它看起来像这样

export function getCalendarEvents() {
  return fetch('http://50520dbf.ngrok.io/api/v1/events/date/')
    .then((response) => response.json())
    .then((responseJson) => {

      this.setState({
        isLoaded: true,
        dataSource: responseJson,
      }, function () {

      });

    })
    .catch((error) => {
      console.error(error);
    });
}
基于这个方法,它按如下顺序返回值

[ 
   { 
      "feedbackLogId":4,
      "time":"3 Weeks Ago",
      "recipient":"10060878",
      "type":"Compliment",
      "sender":"10060878",
      "imageUrl":"",
      "name":"AUNG THU"
   },
   { 
      "feedbackLogId":5,
      "time":"1 Weeks Ago",
      "recipient":"10060878",
      "type":"Compliment",
      "sender":"10060878",
      "imageUrl":"",
      "name":"JUN HAO 3"
   }
]
是否有一种方法可以反转提取的顺序,使其以相反的方式返回,就像这样

[ 
   { 
      "feedbackLogId":5,
      "time":"1 Weeks Ago",
      "recipient":"10060878",
      "type":"Compliment",
      "sender":"10059046",
      "imageUrl":"",
      "name":"JUN HAO 3"
   },
   { 
      "feedbackLogId":4,
      "time":"3 Weeks Ago",
      "recipient":"10060273",
      "type":"Compliment",
      "sender":"10059046",
      "imageUrl":"",
      "name":"AUNG THU"
   }
]

感谢您的帮助和欢呼:)

您可以通过显式地反转数组响应来轻松完成这一任务。
reverse
函数表单可以帮助您实现这一点

您的代码将成为

import { reverse } from 'lodash';
...
      this.setState({
        isLoaded: true,
        dataSource: reverse(responseJson),
      }, function () {
...