0

我测试了很多东西,但我没有到达实现这个我到达将数组发送到后端但我没有到达使用它,因为我得到字符串数组这是一个数组

online_products [
{
  "name":"AMPICILLINE TM 20 mg Gel",
  "code":"74647293"
  "prix":"1000",
  "molecule":'AMPICILLINE',
  "quantity":"true",      
},
{
  "name":"BRUFEN 400 mg Ovule",
  "code":"947473838"
  "prix":"1300",
  "molecule":'AMPICILLINE',
  "quantity":"true",      
},
{
  "name":"GYNO - PVARYL  150 mg Ovule",
  "code":"007472838"
  "prix":"500",
  "molecule":'AMPICILLINE',
  "quantity":"true",      
},
{
  "name":"FORTALINE 93 g  Sirop",
  "code":"792093299"
  "prix":"1500",
  "molecule":'AMPICILLINE',
  "quantity":"true",      
},
{
  "name":"ACCUZON 250 mg Poudre",
  "code":"0483758"
  "prix":"1500",
  "molecule":'AMPICILLINE',
  "quantity":"true",      
}
]

我使用应用程序应用程序/urlencoded 到正文内容,然后将应用程序/json 和授权设置为标头,请问我该怎么做才能在后端 nodejs 中获取数组

4

1 回答 1

0

我已经通过 aplication/json 更改正文内容类型并使用这种数组形式来解决它

{
   "id":"15",
   "products":[
     
     {
       "name":"AMPICILLINE TM 20 mg Gel",
       "code":"74647293",
       "price":"1000",
       "molecule":"AMPICILLINE",
       "quantity":"false"     
     },
     {
       "name":"BRUFEN 400 mg Ovule",
       "code":"947473838",
       "price":"1300",
       "molecule":"AMPICILLINE",
       "quantity":"fasle"      
     },
     {
       "name":"GYNO - PVARYL  150 mg Ovule",
       "code":"007472838",
       "price":"500",
       "molecule":"AMPICILLINE",
       "quantity":"true"      
     }
        
     ]
}

于 2020-10-23T14:07:30.870 回答