42-api.js 中文文档教程

发布于 3年前 浏览 13 项目主页 更新于 3年前

42.js

made-with- javascript

????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

made-with-javascript

????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

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文