RuanAragao / good-luck-api

Random Number Generator and Storage
https://good-luck-api.vercel.app
MIT License
4 stars 4 forks source link

Implement random number on API #8

Closed RuanAragao closed 3 years ago

RuanAragao commented 3 years ago

We have a random number generator (pages/api/utils/random-number.ts) and we need to return a value from it in endpoint /api/number (/pages/api/number.ts).

The number must be 8 digits.

Eg:

{
  "number": "00103178"
}
Raghav-Modani commented 3 years ago

I can give it a shot. Please assign this to me.

RuanAragao commented 3 years ago

I can give it a shot. Please assign this to me.

You can use this PR #10 for orientation.

Raghav-Modani commented 3 years ago

I have a doubt. I am using the dynamic API routes. How are we going to navigate to the API route? I mean are we going to use a button to link to the API URL and passing the random number to the URL?

RuanAragao commented 3 years ago

I have a doubt. I am using the dynamic API routes. How are we going to navigate to the API route? I mean are we going to use a button to link to the API URL and passing the random number to the URL?

You can use an API cliente for your tests, I use Insomnia. The API will be used, first, in the Good Luck Android App

Flux:

  1. The API receives a POST request (or GET is better in this case?)
  2. API return a JSON with the new 8-digit number

Solved? Or I confused your doubt?

Raghav-Modani commented 3 years ago

Okay, now I understood. So basically we will make a POST request from the "Good Luck Android App" to the API whose endpoint contains a random number and that random number will be generated using the random number generator function and we will pass it to the API URL. So I have to create a dynamic API route and a function in that which will fetch the random number from the query of the API URL and will return the JSON with the random number. Please correct me if I understood wrongly!

RuanAragao commented 3 years ago

Yes, is correct!