Mục tiêu ngày 16 🎯
Sau hôm nay bạn sẽ:
✔ Tạo API từ Google Apps Script
✔ Gọi API từ website / mobile / hệ thống khác
✔ Trả dữ liệu dạng JSON chuyên nghiệp
✔ Biến HRM thành backend service thật
API cho phép hệ thống khác gọi dữ liệu:
App khác → API → Apps Script → Google Sheets
Ví dụ:
Website React
Mobile App
Power BI
functiondoGet(e){
constaction=e.parameter.action
if(action=="employees"){
returngetEmployeesAPI()
}
returnContentService
.createTextOutput("Invalid API")
}
functiongetEmployeesAPI(){
constdata=getEmployeesService()
returnContentService
.createTextOutput(JSON.stringify({
success:true,
data:data
}))
.setMimeType(ContentService.MimeType.JSON)
}