Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // bagian providers file DataServices.dart
- import '../utils/config.dart';
- import 'dart:convert';
- import 'package:http/http.dart' as http;
- class DataServices {
- TokenStore(String token){
- Map headers = {
- 'X-Authorization': 'Bearer ${token}'
- };
- return headers;
- }
- LoginAuthentication(Map credentials) {
- print(credentials);
- return http.post(
- '${Config.baseUrl}/auth/login',
- headers: {
- 'X-Requested-With':'XMLHttpRequest',
- 'Content-Type':'application/json',
- 'Cache-Control':'no-cache'
- },
- body: json.encode(credentials)
- );
- }
- //bagian screen
- void submit() {
- if (this._formKey.currentState.validate()) {
- _formKey.currentState.save();
- DataServices().LoginAuthentication({
- "username":_data.email,
- "password": _data.password
- })
- .then((response) => print(json.decode(response.body)));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement