Skip to content

Instantly share code, notes, and snippets.

@john-osullivan
Created September 16, 2019 20:27
Show Gist options
  • Save john-osullivan/1ced99f59f8a2091702a219bcad3784d to your computer and use it in GitHub Desktop.
Save john-osullivan/1ced99f59f8a2091702a219bcad3784d to your computer and use it in GitHub Desktop.
Using Login namespace
import { Login } from '@eximchain/dappbot-types/spec/methods/auth';
import request from 'request-promise-native';
const baseApiUrl = 'https://api.dapp.bot';
async function loginToDappbot(creds:Login.Args):Login.Result {
const res:Login.Response = await request({
headers : { 'Content-Type' : 'application/json' },
method : Login.HTTP,
url : `${baseApiUrl}/${Login.Path}`,
json : creds
});
if (res.data) {
return res.data as Login.Result;
} else if (res.err) {
throw new Error(res.err.message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment