@cfvdb/core
Advanced tools
Comparing version 1.2.3 to 1.3.0
@@ -5,6 +5,7 @@ const axios = require('axios'); | ||
* Fetches the data of card. | ||
* @param query - The query to search for. | ||
* @param name - The name to search for. | ||
* @param options - The extra options of the search. | ||
* @returns {Promise<*>} | ||
*/ | ||
async function search(query, options = {}) { | ||
async function search(name, options = {}) { | ||
if (!options.url) { | ||
@@ -14,6 +15,32 @@ throw new Error('Url of API is not provided.'); | ||
let query = ''; | ||
if (name) { | ||
query += 'name=' + name; | ||
} | ||
if (options.era) { | ||
query += 'era=' + options.era; | ||
} | ||
if (options.grade) { | ||
query += 'grade=' + options.grade; | ||
} | ||
if (options.nation) { | ||
query += 'nation=' + options.nation; | ||
} | ||
if (options.clan) { | ||
query += 'clan=' + options.clan; | ||
} | ||
if (options.rarity) { | ||
query += 'rarity=' + options.rarity; | ||
} | ||
try { | ||
const response = await axios({ | ||
method: 'get', | ||
url: options.url + '?q=' + query | ||
url: options.url + '?' + query | ||
}); | ||
@@ -20,0 +47,0 @@ |
{ | ||
"name": "@cfvdb/core", | ||
"version": "1.2.3", | ||
"version": "1.3.0", | ||
"description": "Core functions for CFVDB", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
28555
574