This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
1. The first issue is that Suspense requires a fallback prop which can be a React Component to be shown to the user as a fallback while the original component | |
in Suspense loads. The code is missing the fallback Prop. | |
2. The second issue is that this code is rendering components first and then fetching which actually is not how Suspense is used, Suspense is used to fetch data | |
and render the component all at the same time. | |
3. For Suspense to work correctly, the fetchUserProfile API call should be similar to React Relay which allows a user to read bits and chunks of data as it | |
becomes available. At the moment, fetchUserProfile looks more like a simple API returning a prmoise which will not work with Suspense. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config() | |
const fs = require('fs') | |
const OpenAI = require('openai') | |
//make sure you have the OPENAI_API_KEY in your .env file | |
const OPENAI_API_KEY = process.env.OPENAI_API_KEY | |
const openai = new OpenAI({ | |
apiKey: OPENAI_API_KEY, |