728x90
반응형
https://github.com/axios/axios
import
import axios from 'axios';
async send_server() {
const server_url = 'http://192.168.25.13/index.php'
let options = {
method: 'POST',
url: server_url,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json; charset=UTF-8'
},
data: {
property_one: "값",
property_two: "값2"
}
};
let response = await axios(options);
console.log(response)
if( response.status === 200 ){
let data = await response.data;
console.log(data)
}
}
async test(){
let pram = {
type : Platform.OS === 'ios' ? 'ios' : 'android',
version:version
}
const server_url = 'http://lovegru.eoapps.co.kr/api/version_check.php'
let options = {
method: 'POST',
url: server_url,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json; charset=UTF-8'
},
data: JSON.stringify(pram)
};
let response = await axios(options);
console.log(response)
if (response.status === 200) {
let data = await response.data;
console.log(data)
}
}
/* async test_axios(url,request_params){
let result = '';
let options = {
method: 'POST',
url: url,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
data: JSON.stringify(request_params),
}
console.log(url+"===>","common - api_call - request_params >{\n}",JSON.stringify(request_params))
let response = await axios(options);
if (response.status === 200) {
let data = await response.data;
console.log(data)
result = data.json()
} else {
let data = await response.data;
result = data.json()
}
console.log("****************Result*****************")
console.log(result)
console.log("*********************************************\n\n\n\n\n")
}
*/
728x90
반응형
'React Native' 카테고리의 다른 글
자바스크립트 배열 (0) | 2020.04.22 |
---|---|
react native Image cache 문제. (0) | 2020.04.20 |
Flatlist, ScrollView 속성 (0) | 2020.03.11 |
FlexBox (0) | 2020.03.09 |
ScrollView 와 FlatList 방향 겹치는 문제. (0) | 2020.03.02 |