session.post(
'http://myopencart.example.com/index.php?route=api/cart/add',
params={'api_token':'768ef1810185cd6562478f61d2'},
data={
'product_id':'100'
'quantuty':'1'
}
)
How to I post this in flutter. In this api there is two type of data to be posted.
I need solution for this I didn’t tried yet.
3
Answers
To send HTTP requests in Flutter you can use one of the many packages available. Some examples:
Example with
http
packageYou first need to add the package to the dependencies:
Then you could write a function the be called for example when you press a button:
First, let’s analyze the api requested parameters:
http://myopencart.example.com/index.php?route=api/cart/add is the url
‘api_token’:’768ef1810185cd6562478f61d2′ should be put in header
{
‘product_id’:’100′
‘quantuty’:’1′
} are arguments which will be in the boday
Here is how you can perform the request using Http