Environment Variables in External APIs
In this video tutorial you will learn how to use Environment Variables in External APIs.
1. Configure Environment Variables
To do this go to Settings > App Settings and you will find Environment Variables. Here add the variable you want to create, paste the value and choose Choose the same value for the existing environment and click Create.
2. Choose the Environment
You can choose from the two environments namely Preview/ Staging or Production/live and even create separate tokens for the two. For this click Edit.
3. Adding the Token
Go to External API and click the + sign. Under Environment Variables the newly generated token will display. Again choose the + sign to add this token in the field and Save Setting.
4. Update the Environment Variable
For this go to the External API and choose the field and the + sign and when the token is displayed edit it and click Update.
5. Test the Token
Since you have updated the token incorrectly now when you create a new record it will give an Error message.
6. Create New Environment Variable
To do this go to Settings > App Settings and you will find Environment Variables. Here add the variable you want to create, paste the value and choose Choose the same value for the existing environment and click Create.
7. Copy the Token from External API
Go to your external API ?(Airtable) and copy the token from here.
8. Choose New Environment
You can choose from the two environments namely Preview/ Staging or Production/live and even create separate tokens for the two. For this click Edit and paste the token copied form the external API and click Update.
This way you can segregate data for both the preview and production environments.
9. Reload External API
Go to the External API page and reload it. The new token will reflect here.
10. Get Token from Environment Variables
Since you do not want the token hardcoded in the above step, click the + sign and under Environment Variables choose the + sign again. The new token will display in this section. Then Save Setting.
11. Preview the Changes
Now you can add data or create records in your preview and publish environments and have them separated in your external API.