Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F7859945
single-resource-api.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
single-resource-api.js
View Options
const
axios
=
require
(
"axios"
);
const
CachedHttp
=
require
(
"../cached-http.js"
);
const
EventEmitter
=
require
(
"events"
);
const
SingleItemResponse
=
require
(
"../../common_lib/response/single-item-response.js"
);
module
.
exports
=
class
SingleResourceAPI
extends
EventEmitter
{
constructor
(
collection_name
,
id
,
options
)
{
super
();
this
.
id
=
id
;
this
.
collection_name
=
collection_name
;
this
.
response
=
null
;
this
.
loading
=
true
;
this
.
filter
=
(
options
&&
options
.
filter
)
||
{};
this
.
format
=
(
options
&&
options
.
format
)
||
{};
this
.
attachments
=
(
options
&&
options
.
attachments
)
||
{};
}
setLoading
(
loading
)
{
this
.
loading
=
loading
;
this
.
emit
(
"change"
,
this
.
response
);
}
load
()
{
this
.
loading
=
true
;
return
this
.
_load
();
}
async
_load
()
{
const
http_response
=
await
CachedHttp
.
get
(
`/api/v1/collections/
${
this
.
collection_name
}
/
${
this
.
id
}
`
,
{
filter
:
this
.
filter
,
format
:
this
.
format
,
attachments
:
this
.
attachments
,
}
);
this
.
response
=
new
SingleItemResponse
(
http_response
);
this
.
setLoading
(
false
);
}
async
patch
(
body
)
{
this
.
loading
=
true
;
await
axios
.
patch
(
`/api/v1/collections/
${
this
.
collection_name
}
/
${
this
.
id
}
`
,
body
);
CachedHttp
.
flush
();
return
this
.
_load
();
}
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 13, 17:11 (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
872664
Default Alt Text
single-resource-api.js (1 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment