Bỏ qua, đến nội dung

Cấu hình node - HTTP Request ​

Node gọi API bên ngoài hoặc endpoint nội bộ, hỗ trợ tất cả HTTP methods với URL, headers, body từ template biến workflow.

Bảng tham số cấu hình ​

Tham sốKiểuBắt buộcMặc địnhMô tả
methodstringCó—HTTP method: GET, POST, PUT, PATCH, DELETE
urlstringCó—URL đích (hỗ trợ template biến workflow)
headersobjectKhông{}HTTP headers tùy chỉnh
paramsobjectKhông{}Query parameters
bodyobject/stringKhông—Request body (JSON hoặc text)
timeoutnumberKhông5000Timeout request (ms)
ignoreFailbooleanKhôngfalseKhi true, workflow tiếp tục ngay cả khi request lỗi
contentTypestringKhôngapplication/jsonContent-Type: application/json, form-data, x-www-form-urlencoded

Dữ liệu đầu ra (Output) ​

TênKiểuMô tả
statusCodenumberHTTP status code từ response
headersobjectResponse headers
bodyanyResponse body (auto-parse JSON)

Xử lý HTTP status code ​

StatusignoreFail = falseignoreFail = true
2xxThành công, tiếp tụcTiếp tục
3xxFollow redirectFollow redirect
4xxDừng workflowTiếp tục (body = error)
5xxDừng workflowTiếp tục (body = error)
TimeoutDừng workflowTiếp tục (body = null)

Lưu ý quan trọng ​

  • Timeout mặc định 5 giây - tăng lên cho API chậm (file upload, báo cáo)
  • ignoreFail: true giữ workflow chạy khi API lỗi - kiểm tra statusCode ở node sau
  • Response body quá lớn có thể ảnh hưởng memory - dùng JSON Query/Get JSON Field để chỉ lấy field cần
  • Headers nhạy cảm (API key, token) nên lưu trong biến môi trường hoặc config
  • POST request có thể tạo duplicate nếu API không idempotent - cẩn thận khi retry