URLSearchParams 可以將URL中的查詢參數 例如 'https://example.api?userId=1234&name=John Doe'當中的?userId=1234&name=John Doe 轉換成物件並使用get,append,delete等方法取出內容 例如
const params = new URLSearchParams('?userId=1234&name=John%20Doe');
console.log(params.get('userId')); // 1234
res.status(status): 這個部分會呼叫 Express.js 的回應物件 (response object) 上的 status 方法,並傳入指定的 status 參數。 status 方法會用於設定 HTTP 回應的狀態代碼. 呼叫 status 方法後,它會回傳 Express.js 的回應物件 (response object) 本身,因此可以繼續對這個物件進行其他操作,例如設定標頭等等。
json(data): 這個部分會呼叫 Express.js 的回應物件 (response object) 上的 json 方法,並傳入指定的 data 參數。 json 方法會將提供的 data 參數轉換成 JSON 字串,並設定為回應的內容. 因此,整個箭頭函式的功能就是:
設定 HTTP 回應的狀態代碼為 status. 將 data 參數轉換成 JSON 字串,並設定為回應的內容.