X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=lib%2Fproduct_service.dart;h=218b16937ae027cfd302425ef52113aa03e984a5;hb=74001e08303ce797811fc91816a67c2006fe0a25;hp=41af5cb9e3f81ad1d3c8cffeed3dc09397cc1d4c;hpb=8efc1c411ba4d97505c3836bd78bb5e68f521e2e;p=outofuni%2Ftavern2.git diff --git a/lib/product_service.dart b/lib/product_service.dart index 41af5cb..218b169 100644 --- a/lib/product_service.dart +++ b/lib/product_service.dart @@ -57,19 +57,20 @@ class ProductService { } } - Future createProduct(String name,double price,String cat) async { + Future createProduct(String name,double pri,String cat) async { try { var url=_server+'/'+_db; - await _http.post( + var response = await _http.post( url, headers: {'Content-Type': 'application/json'}, body: JSON.encode({ 'name': name, - 'price': price, + 'price': pri, 'type': 'product', 'category': cat }) ); + return(JSON.decode(response.body)['id']); } catch(e) { throw _handleError(e);