UNPKG

rocketdata

Version:

**Rocketdata** is a modern, lightweight Node.js wrapper for [NASA's public APIs](). Easily fetch data from the Astronomy Picture of the Day (APOD), Mars Rover imagery, and more — all with clean, promise-based functions.

41 lines 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAstronomyPictureOfTheDay = void 0; var tslib_1 = require("tslib"); var axios_1 = tslib_1.__importDefault(require("axios")); var util_1 = require("./util"); var NASA_API_URL = 'https://api.nasa.gov'; var APOD_API = "".concat(NASA_API_URL, "/planetary/apod"); /** * @function getAstronomyPictureOfTheDay * @version 2.0.2 * @param {ApodRequestParams} params - The request parameters. * @returns {Promise<ApodResponse>} * @fulfill {ApodResponse} - The astronomy picture of the day. * @reject {Error} - The error object. * @description getAstronomyPictureOfTheDay is a function that returns the Astronomy Picture of the Day from NASA's API. * @example * const result = await getAstronomyPictureOfTheDay({ * date: '2023-06-25', * start_date: '2023-06-20', * end_date: '2023-06-25', * count: 5, * thumbs: true, * api_key: 'DEMO_KEY', * }); */ var getAstronomyPictureOfTheDay = function (params) { return tslib_1.__awaiter(void 0, void 0, void 0, function () { var query, response; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: query = (0, util_1.buildQueryParams)(params); return [4 /*yield*/, axios_1.default.get("".concat(APOD_API, "?").concat(query))]; case 1: response = _a.sent(); return [2 /*return*/, response.data]; } }); }); }; exports.getAstronomyPictureOfTheDay = getAstronomyPictureOfTheDay; //# sourceMappingURL=apod.js.map