如何将 fetch 中的 NULL 值传递给后端进行更新?

How to pass NULL value in fetch to backend for update?

在我的 React Native 0.66 应用程序中,这里是 fetch 用于更新后端数据库:

let update = {
  status:"BidPlaced",
  buyer_id:Null, //<<==how to pass NULL for update?
  buy_date:NULL,  //<<==how to pass NULL for update?
};


res = await fetch(url, {. 
  method: "POST",
  headers: {
    'Accept': 'application/json, text/plain',
    'Content-Type': 'application/json',   
  },
  body: JSON.stringify(update), 
});

需要将fetch中的NULL值传递给后端(nodejs+sequelize/postgres)进行更新。我注意到如果使用空字符串 buyer_id: , buy_date: ,那么 JSON.stringify 将忽略它们,因为没有为 buyer_idbuy_date 提供任何值。在 fetch 中发送 NULL 以更新后端即 nodejs 和 sequelize/postgres 的正确方法是什么?

您需要使用 null 而不是 NULLNull