I am using the below code to get Marvel API data:
const axios = require('axios');
const md5 = require('blueimp-md5');
const publickey = 'publickey';
const privatekey = 'privatekey';
const ts = new Date().getTime();
const stringToHash = ts + privatekey + publickey;
const hash = md5(stringToHash);
const baseUrl = 'https://gateway.marvel.com:443/v1/public/characters';
const url = baseUrl + '?ts=' + ts + '&apikey=' + publickey + '&hash=' + hash;
async function getMarvel(){
const { data } = await axios.get(url);
return data;
}
Below is fragment of the output:
{
"id": 1009150,
"name": "Agent Zero",
"description": "",
"modified": "1969-12-31T19:00:00-0500",
"thumbnail": {
"path": "http://i.annihil.us/u/prod/marvel/i/mg/f/60/4c0042121d790",
"extension": "jpg"
},
{
"id": 1011031,
"name": "Agent X (Nijo)",
"description": "Originally a partner of the mind-altering assassin Black Swan, Nijo spied on Deadpool as part of the Swan's plan to exact revenge for Deadpool falsely taking credit for the Swan's assassination of the Four Winds crime family, which included Nijo's brother.",
"modified": "1969-12-31T19:00:00-0500",
"thumbnail": {
"path": "http://i.annihil.us/u/prod/marvel/i/mg/b/40/image_not_available",
"extension": "jpg"
},
If I want only Agent Zero from my API call can I do something like this:
const baseUrl = 'https://gateway.marvel.com:443/v1/public/characters?name=Agent+Zero';
This throws a 409 error, what can I change to get only one agent data?