尝试使用可以从 curl 等调用的请求模块创建 api。 你能帮忙检查一下这里是否做错了
> class mProductUnit(models.Model):
mProductUnit_id = models.AutoField(primary_key=True)
mProductUnit_name = models.CharField(max_length=10)
def __str__(self):
return self.mProductUnit_name
错误
request({
url: 'http:asdasd/testapi',
method: 'POST',
headers: {"content-type": "application/json"},
body: {
'id':1,
'name':'xxxx'
},
json: true
}, function (error, result, body) {
if (error) {
console.log(error);
} else if (result.statusCode === 500) {
console.log('error');
} else {
console.log(body);
}
});