Fetch - Call API
Fetch 提供簡易的設定,讓串接 API 的工作變得更直覺、更輕鬆
HTTP POST
Fetch f = new Fetch("https://httpbin.org/post");
// 自訂 header
f.Header = new
{
Access_Token = "123456789"
};
// 自訂 cookie
f.Cookie = new
{
account = "Gold"
};
// 查詢字串: ?qs=dog
var query_str = new
{
qs = "dog"
};
// 傳送資料: { id: 100, ... }
var json_data = new
{
id = 100,
name = "zap",
data = new List<object>()
{
new { sid=10, name="book" },
new { sid=10, name="pen" },
}
};
// 發出請求
string result = f.Post(json_data, query_str);
if (result == null) Console.WriteLine(f.GetResponse());
else Console.WriteLine(result);Other HTTP Methods
Mapping JSON to Model
Declare Data Model
Specify The Model
Dynamic Request Configuration
Form Data
Attach Files
Response Header
Last updated