Skip to content

Commit 88fba30

Browse files
Add findEntity method to ContextBroker class
1 parent 2963df7 commit 88fba30

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@faubourg-numerique/ngsi-ld",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "",
55
"main": "dist/index.js",
66
"scripts": {

src/ContextBroker.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ export class ContextBroker {
1616
this.contextBrokerMaxLimit = contextBrokerMaxLimit;
1717
}
1818

19+
async findEntity(id: string) {
20+
const response = await this.client.get(`/entities/${encodeURIComponent(id)}`);
21+
return new Entity(response.data);
22+
}
23+
1924
async findEntities({ type, query }: { type?: string, query?: string }) {
2025
const config: AxiosRequestConfig = {
2126
params: {
@@ -25,7 +30,6 @@ export class ContextBroker {
2530
offset: 0
2631
}
2732
};
28-
2933
const entities: Entity[] = [];
3034
while (true) {
3135
const response = await this.client.get("/entities", config);

0 commit comments

Comments
 (0)