LoginSignup
0
0

paiza.ioでnode.js その2

Posted at

概要

paiza.ioでnode.js、やってみた。
練習問題やってみた。

練習問題

note.comのAPIを叩け。

サンプルコード

process.stdin.resume();
process.stdin.setEncoding('utf8');

let http = require('https');

const URL = 'https://note.com/api/v2/creators/ohisama_llc';

http.get(URL, (res) => {
  let body = '';
  res.setEncoding('utf8');
  res.on('data', (chunk) => {
      body += chunk;
  });
  res.on('end', (res) => {
      res = JSON.parse(body);
      console.log(res);
  });
}).on('error', (e) => {
  console.log(e.message);
});


実行結果

{
  data: {
    id: 9300283,
    key: '987004565a00a3a690ca251ce4a1629a',
    nickname: 'ohisama',
    urlname: 'ohisama_llc',
    profile: '',
    noteCount: 1,
    magazineCount: 0,
    followingCount: 1,
    followerCount: 0,
    isFollowing: false,
    isFollowed: false,
    isMyself: false,
    originalHeaderImageUrl: null,
    headerImageUrl: null,
    headerImageKey: null,
    profileImageUrl: 'https://d2l930y2yx77uc.cloudfront.net/assets/default/default_profile_4-e3b57528da29acad20d5a2db33268c87f1d39015448757ddf346d60fb5861e49.png',
    profileImageKey: null,
    isBlocked: false,
    blocksYou: false,
    isAdmin: false,
    socials: {},
    isOfficial: false,
    showFollowCount: true,
    externalLinks: {},
    disableSupport: false,
    hasStore: false,
    hasCircle: false,
    customDomain: null,
    followAppealText: null,
    followAppealImage: null,
    isCreatorLikesTabEnabled: true,
    isCreatorMagazinesTabEnabled: true,
    isCreatorCirclesTabEnabled: true,
    isCreatorArchivesTabEnabled: true,
    isCreatorProfileTabEnabled: false,
    isCreatorJobOfferTabEnabled: false,
    isCreatorFollowNumberDisplayed: true,
    style: 'streem',
    isPro: false,
    proUserId: null,
    tlMagazines: [],
    isMedia: false,
    storeUrl: '',
    jobSourceUrl: null,
    isHavingSubscribableMagazines: false
  }
}

成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0