【问题标题】:How to update a single attribute?如何更新单个属性?
【发布时间】:2019-09-19 06:48:23
【问题描述】:

当我在我的应用程序上上传新资产时,我只需要在数据库中更新uri 属性。

function assegnaUri(hash_referto, proprietario, public_key, data_esame, tipo_esame, uri) {

   fetch('http://localhost:8080/api/REFERTOs', {
   method: 'POST',
   headers: { 
   Accept: 'application/json',
  'Content-Type': 'application/json',
    },
     body: JSON.stringify({
   "hash_referto":hash_referto,
   "proprietario":proprietario,
   "public_key":public_key,
   "data_esame": data_esame, 
   "tipo_esame":tipo_esame,
   "uri":uri
     }),
 });
 } 

hash_referto 是 id,我只需要使用 id 获取正确的元组并将 urinull 上传到存储在 referto 中的值

【问题讨论】:

    标签: javascript mysql reactjs loopbackjs


    【解决方案1】:

    不清楚你想做什么,它认为你想要一个 UPDATE 请求?

    function assegnaUri(hash_referto, uri) {
    
       fetch('http://localhost:8080/api/REFERTOs', {
       method: 'PUT',
       headers: { 
       Accept: 'application/json',
      'Content-Type': 'application/json',
        },
         body: JSON.stringify({
       hash_referto:hash_referto,
       uri:uri
         }),
     });
     } 
    

    我总是使用 PUT 请求来更新一些东西,如果你愿意,我们可以深入了解细节,现在你需要在后端处理这个请求

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多