Postingan lainnya
get and post api android
permisi, mau nanya cara ngelempar dan menerima api di android? contoh kecilnya login.
0
1 Jawaban:
GET & POST ke API, menggunakan apa? Android Studio? Cordova / Phonegap? Ionic?
jika menggunakan ionic2, bisa dengan menambahkan native http, pemakaian GET :
import { HTTP } from 'ionic-native';
HTTP.get('http://ionic.io', {}, {})
.then(data => {
console.log(data.status);
console.log(data.data); // data received by server
console.log(data.headers);
})
.catch(error => {
console.log(error.status);
console.log(error.error); // error message as string
console.log(error.headers);
});
jika POST :
import { HTTP } from 'ionic-native';
HTTP.post('http://ionic.io', $variable_post)
.then(data => {
console.log(data.status);
console.log(data.data); // data received by server
console.log(data.headers);
})
.catch(error => {
console.log(error.status);
console.log(error.error); // error message as string
console.log(error.headers);
});
referensi : http://ionicframework.com/docs/v2/native/http/
0