mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-12 10:15:32 +00:00
Perform "addstock" action
This commit is contained in:
21
lib/api.dart
21
lib/api.dart
@ -59,7 +59,7 @@ class InvenTreeAPI {
|
||||
|
||||
String makeApiUrl(String endpoint) {
|
||||
|
||||
return apiUrl + endpoint;
|
||||
return _makeUrl("/api/" + endpoint);
|
||||
}
|
||||
|
||||
String makeUrl(String endpoint) {
|
||||
@ -272,20 +272,18 @@ class InvenTreeAPI {
|
||||
}
|
||||
|
||||
// Perform a POST request
|
||||
Future<http.Response> post(String url, {Map<String, String> body}) async {
|
||||
Future<http.Response> post(String url, {Map<String, dynamic> body}) async {
|
||||
|
||||
var _url = makeApiUrl(url);
|
||||
var _headers = defaultHeaders();
|
||||
var _body = Map<String, String>();
|
||||
|
||||
// Copy across provided data
|
||||
body.forEach((K, V) => _body[K] = V);
|
||||
var _headers = jsonHeaders();
|
||||
|
||||
print("POST: " + _url);
|
||||
|
||||
var data = jsonEncode(body);
|
||||
|
||||
return http.post(_url,
|
||||
headers: _headers,
|
||||
body: _body,
|
||||
body: data,
|
||||
);
|
||||
}
|
||||
|
||||
@ -324,6 +322,13 @@ class InvenTreeAPI {
|
||||
return headers;
|
||||
}
|
||||
|
||||
Map<String, String> jsonHeaders() {
|
||||
|
||||
var headers = defaultHeaders();
|
||||
headers['Content-Type'] = 'application/json';
|
||||
return headers;
|
||||
}
|
||||
|
||||
String _authorizationHeader () {
|
||||
if (_token.isNotEmpty) {
|
||||
return "Token $_token";
|
||||
|
Reference in New Issue
Block a user