-
Notifications
You must be signed in to change notification settings - Fork 0
Week 08 ‐ Devlog
Postman can be downloaded and installed here: https://www.postman.com/downloads/
Some of the environmental variables will be hidden and not uploaded, obviously, to this public GitHub repo. However, I can go through how it is used to test the APIs in the FirstFrostMVP database.
When setting up Postman, I created a new collection and named it after the app. The pre-request script is at the collection level:
const token = pm.environment.get("accessToken");
if (token) {
pm.request.headers.add({
key: "Authorization",
value: `Bearer ${token}`
});
}
pm.request.headers.add({
key: "apikey",
value: pm.environment.get("anonKey")
});
Environment was created, everything inputted, and collection created. However, first we need to create a new POST request.
-
Name:
Auth: Sign In - Method: POST
-
URL:
{{baseUrl}}/auth/v1/token?grant_type=password -
Headers:
Content-Type: application/json - Body (raw JSON):
JSON:
{
"email": "rae@firstfrost.app",
"password": "xxxxxxxxx"
}
Scripts > Post-response
const res = pm.response.json();
pm.environment.set("accessToken", res.access_token);
pm.environment.set("userId", res.user.id);
The first time I tried to POST, I realized I had not set the environment in the top right to the recently edited one (one with all the .env data). After connecting it, ran the previous query after making sure I did not make the mistake of running it with the name as baseURL instead of baseUrl because it is case-sensitive.
I updated my test email with a password via SQL since the frontend client and sign-up/onboarding is not up yet. After updating the Postman request body with that password, we are able to generate an access code and userId to be stored automatically in the environment.
Now, we can commit the collection file and basic environment setup to the repo (but of course make sure to delete sensitive data like the accessToken)
- https://github.com/givecoffee/firstfrostmvp/issues/14
- https://github.com/givecoffee/firstfrostmvp/issues/15
- Postman environment configured and auth request returning 200.
- Email rate limiting on Supabase free tier required inserting users directly via SQL and setting passwords with
crypt()
postman dashboard
postman collection