LoginSignup
0
0

paiza.ioでnode.js その3

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/contents?kind=note&page=1';

http.get(URL, (res) => {
    let body = '';
    res.setEncoding('utf8');
    res.on('data', (chunk) => {
        body += chunk;
    });
    res.on('end', (res) => {
        res = JSON.parse(body);
        for (let i = 0 ; i < res.data.contents.length ; i++) 
        {
		    console.log(res.data.contents[i]);
        }
    });
}).on('error', (e) => {
    console.log(e.message);
});




実行結果

{
  id: 85083791,
  type: 'ImageNote',
  status: 'published',
  name: 'カイエンを落札。',
  description: null,
  likeCount: 0,
  price: 0,
  key: 'ne68397ab6365',
  slug: 'slug-ne68397ab6365',
  publishAt: '2024-04-27T10:29:25+09:00',
  thumbnailExternalUrl: '',
  eyecatch: 'https://assets.st-note.com/img/1714181237850-Bv1ufY66yb.jpg?fit=bounds&quality=85&width=1280',
  user: {
    id: 9300283,
    key: '987004565a00a3a690ca251ce4a1629a',
    name: 'ohisama',
    urlname: 'ohisama_llc',
    nickname: 'ohisama',
    userProfileImagePath: 'https://d2l930y2yx77uc.cloudfront.net/assets/default/default_profile_4-e3b57528da29acad20d5a2db33268c87f1d39015448757ddf346d60fb5861e49.png',
    customDomain: null,
    disableSupport: false,
    disableGuestPurchase: false,
    emailConfirmedFlag: true,
    likeAppealText: 'ありがとう!励みになります!',
    likeAppealImage: 'https://assets.st-note.com/poc-image/manual/production/preset_reaction_4.png',
    purchaseAppealTextNote: null,
    twitterNickname: null,
    shareAppeal: { text: null, image: null },
    magazineAddAppeal: { text: null, image: null }
  },
  canRead: true,
  isAuthor: false,
  externalUrl: null,
  customDomain: null,
  body: null,
  separator: null,
  isLimited: false,
  isTrial: false,
  canUpdate: false,
  tweetText: 'カイエンを落札。|ohisama #note',
  twitterRelatedAccounts: 'note_PR',
  isRefund: false,
  isLiked: false,
  commentCount: 0,
  likes: [],
  anonymousLikeCount: 0,
  disableComment: false,
  hashtags: [ { hashtag: [Object] } ],
  twitterShareUrl: 'https://twitter.com/intent/tweet?url=https://note.com/ohisama_llc/n/ne68397ab6365&text=%E3%82%AB%E3%82%A4%E3%82%A8%E3%83%B3%E3%82%92%E8%90%BD%E6%9C%AD%E3%80%82%EF%BD%9Cohisama+%23note&related=note_PR',
  facebookShareUrl: 'https://www.facebook.com/share.php?u=https://note.com/ohisama_llc/n/ne68397ab6365&t=%E3%82%AB%E3%82%A4%E3%82%A8%E3%83%B3%E3%82%92%E8%90%BD%E6%9C%AD%E3%80%82%EF%BD%9Cohisama%EF%BD%9Cnote%EF%BC%88%E3%83%8E%E3%83%BC%E3%83%88%EF%BC%89',
  lineShareUrl: 'https://line.naver.jp/R/msg/text/?%E3%82%AB%E3%82%A4%E3%82%A8%E3%83%B3%E3%82%92%E8%90%BD%E6%9C%AD%E3%80%82%EF%BD%9Cohisama%EF%BD%9Cnote%EF%BC%88%E3%83%8E%E3%83%BC%E3%83%88%EF%BC%89%0Ahttps://note.com/ohisama_llc/n/ne68397ab6365',
  audio: {},
  pictures: [
    {
      key: '1714181237850-Bv1ufY66yb',
      path: 'img/1714181237850-Bv1ufY66yb.jpg',
      url: 'https://assets.st-note.com/img/1714181237850-Bv1ufY66yb.jpg',
      caption: 'オークションの写真です。'
    }
  ],
  limitedMessage: null,
  labels: [],
  priorSale: null,
  canMultipleLimitedNote: false,
  isMembershipConnected: false,
  hasAvailableCirclePlans: false,
  isPinned: false,
  pinnedUserNoteId: null,
  spEyecatch: 'https://assets.st-note.com/img/1714181237850-Bv1ufY66yb.jpg?fit=bounds&format=jpeg&quality=85&width=110',
  enableBacktoDraft: false,
  notificationMessages: [],
  isProfiled: false,
  isForWork: false,
  isCircleDescription: false,
  noteDraft: null,
  noteUrl: 'https://note.com/ohisama_llc/n/ne68397ab6365',
  imageCount: 1,
  format: '3.0',
  capabilities: { rubyText: false, formulaText: false, duplication: false },
  discountCampaigns: [],
  freeBodyCharNum: 0
}

成果物

以上。

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