mirror of
https://github.com/frappe/books.git
synced 2024-12-23 03:19:01 +00:00
rest_api: /api/resource/doctype/name/fieldname
This commit is contained in:
parent
920767717b
commit
1e9701d0be
@ -89,6 +89,15 @@ module.exports = class RESTClient {
|
||||
.join('&');
|
||||
}
|
||||
|
||||
async get_value(doctype, name, fieldname) {
|
||||
let url = this.protocol + '://' + path.join(this.server, `/api/resource/${frappe.slug(doctype)}/${name}/${fieldname}`);
|
||||
let response = await frappe.fetch(url, {
|
||||
method: 'GET',
|
||||
headers: this.json_headers
|
||||
});
|
||||
return (await response.json()).value;
|
||||
}
|
||||
|
||||
init_type_map() {
|
||||
this.type_map = {
|
||||
'Currency': true
|
||||
|
@ -51,6 +51,12 @@ module.exports = {
|
||||
return response.json(doc.get_valid_dict());
|
||||
}));
|
||||
|
||||
// get value
|
||||
app.get('/api/resource/:doctype/:name/:fieldname', frappe.async_handler(async function(request, response) {
|
||||
let value = await frappe.db.get_value(request.params.doctype, request.params.name, request.params.fieldname);
|
||||
return response.json({value: value});
|
||||
}));
|
||||
|
||||
// delete
|
||||
app.delete('/api/resource/:doctype/:name', frappe.async_handler(async function(request, response) {
|
||||
let doc = await frappe.get_doc(request.params.doctype, request.params.name)
|
||||
|
Loading…
Reference in New Issue
Block a user