42-api.js 中文文档教程
42.js
????Work in progress????
一个用于获取 42 api
Table of Contents
Install
npm install 42-api.js
pnpm install 42-api.js
Usage
const Api42 = require('42-api.js');
const client = new Api42({ clientId: client_id, clientSecret: client_secret });
async function GetData() {
const token = await client.GetToken();
console.log(token);
const newToken = await client.GenerateToken();
console.log(newToken);
const validity = await client.RefreshToken();
console.log(validity);
const users = await client.GetUsers({"filter[login]": 'login'});
console.log(users);
const userCursus = await client.GetUserCursus('login');
console.log(userCursus);
const userLog = await client.GetUserLocationStats('login')
console.log(userLog);
const coalitions = await client.GetCoalitions();
console.log(coalitions);
}
GetData();
Or
const Api42 = require('42-api.js');
const client = new Api42({ clientId: client_id, clientSecret: client_secret });
client.GetToken().then((data) => {
console.log(data);
});
client.GenerateToken().then((data) => {
console.log(data);
});
client.RefreshToken().then((data) => {
console.log(data);
});
client.GetUsers({"filter[login]": 'login'}).then((data) => {
console.log(data);
});
client.GetUserCursus('login').then((data) => {
console.log(data);
});
client.GetUserLocationStats('login').then((data) => {
console.log(data);
});
client.GetCoalitions().then((data) => {
console.log(data);
});
License
MIT © X3ne的小型 npm 模块
42.js
????Work in progress????
An small npm module to fetch the 42 api
Table of Contents
Install
npm install 42-api.js
pnpm install 42-api.js
Usage
const Api42 = require('42-api.js');
const client = new Api42({ clientId: client_id, clientSecret: client_secret });
async function GetData() {
const token = await client.GetToken();
console.log(token);
const newToken = await client.GenerateToken();
console.log(newToken);
const validity = await client.RefreshToken();
console.log(validity);
const users = await client.GetUsers({"filter[login]": 'login'});
console.log(users);
const userCursus = await client.GetUserCursus('login');
console.log(userCursus);
const userLog = await client.GetUserLocationStats('login')
console.log(userLog);
const coalitions = await client.GetCoalitions();
console.log(coalitions);
}
GetData();
Or
const Api42 = require('42-api.js');
const client = new Api42({ clientId: client_id, clientSecret: client_secret });
client.GetToken().then((data) => {
console.log(data);
});
client.GenerateToken().then((data) => {
console.log(data);
});
client.RefreshToken().then((data) => {
console.log(data);
});
client.GetUsers({"filter[login]": 'login'}).then((data) => {
console.log(data);
});
client.GetUserCursus('login').then((data) => {
console.log(data);
});
client.GetUserLocationStats('login').then((data) => {
console.log(data);
});
client.GetCoalitions().then((data) => {
console.log(data);
});
License
MIT © X3ne