I am trying to execute the an API which I found on rapidapi.com.
The url of the API is https://rapidapi.com/sheharyar566/api/random-words5/?utm_source=ANIA-KUBOW&utm_medium=DevRel&utm_campaign=DevRel.
I copied the code from the site which includes the "X-RapidAPI-Key" value when you are logged in.
But when I execute the code on node, I get the message "You are not subscribed to this API."
How do I get it to return the correct result, which is a randomly generated word?
Below is the code:
import fetch from 'node-fetch';
const options = {
method: "GET",
headers: {
"X-RapidAPI-Key": "KEY-GOES-HERE",
"X-RapidAPI-Host": "random-words5.p.rapidapi.com",
},
};
fetch(
"https://random-words5.p.rapidapi.com/getMultipleRandom?count=5&wordLength=5",
options
)
.then((response) => response.json())
.then((response) => console.log(response))
.catch((err) => console.error(err));
And below is the error message:
{ message: 'You are not subscribed to this API.' }
CodePudding user response:
As the error message states, you are not subscribed to the API. RapidAPI supports 3 tiers of subscriptions:
- Free
- Freemium
- Paid
On free APIs, the subscription will be auto-created on the first call. For freemium and paid, you will need to navigate the plans
tab and select the right plan for you.
In your case, go to https://rapidapi.com/sheharyar566/api/random-words5/pricing and select one of the plans.