Skip to content

Instantly share code, notes, and snippets.

@zgorizzo69
Created November 14, 2018 18:23
Show Gist options
  • Save zgorizzo69/58f803dc9eb62f386e72f444c8a0a6c5 to your computer and use it in GitHub Desktop.
Save zgorizzo69/58f803dc9eb62f386e72f444c8a0a6c5 to your computer and use it in GitHub Desktop.
blockstack search and lookup
private searchUrl = 'https://core.blockstack.org/v1/search';
public searchContacts(queryValue: string): Observable<ContactSearchResult[]> {
if (!queryValue || queryValue.trim().length < 1) {
return of(new Array<ContactSearchResult>());
}
return this.http.get<BlockstackSearchResponse>(this.searchUrl, { params: { query: queryValue.trim() } })
.pipe(
map((r: BlockstackSearchResponse) => {
return r.results.map(i => this.mapToSearchResult(i));
})
);
}
lookupProfile(userIdToLookup) {
blockstack.lookupProfile(userIdToLookup)
.then((profile) => {
console.log('user profile:', profile);
})
.catch((err) => console.error(err));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment