我正在尝试从数字列表中提取国家/地区代码前缀,并将它们与它们所属的区域进行匹配。数据可能看起来像这样:
| id | phone_number |
|----|----------------|
| 1 | +27000000000 |
| 2 | +16840000000 |
| 3 | +10000000000 |
| 4 | +27000000000 |
Run Code Online (Sandbox Code Playgroud)
这里的国家代码是:
期望的结果是这样的:
| country | count |
|-----------------------------|-------|
| South Africa | 2 |
| American Samoa | 1 |
| United States and Caribbean | 1 |
Run Code Online (Sandbox Code Playgroud)
有一些困难是因为
这是我当前的解决方案:
SELECT
CASE
WHEN SUBSTRING(phone_number,1,5) = '+1684' THEN 'American Samoa'
WHEN SUBSTRING(phone_number,1,5) = '+1264' …Run Code Online (Sandbox Code Playgroud) 我试图用fetch()我的React Native Component中的函数处理错误的HTTP响应.我使用了这里的代码,建议创建一个模块来处理响应错误.
// ApiUtils.js
var ApiUtils = {
checkStatus: function(response) {
if (response.status >= 200 && response.status < 300) {
return response;
} else {
let error = new Error(response.statusText);
error.response = response;
throw error;
}
}
};
export { ApiUtils as default };
Run Code Online (Sandbox Code Playgroud)
这是我的组件的代码:
import React, { Component } from 'react';
import {View, Text, StyleSheet, Slider, ListView} from 'react-native';
import GLOBAL from "../../Globals.js"
import ApiUtils from "../utils/ApiUtils.js"
class FetchedList extends Component {
constructor(props) …Run Code Online (Sandbox Code Playgroud)