I defined parameter like this.
type ChatCallApiRequest = {
system_prompt?:string,
user_prompt?:string,
messages?: Message[]
model:string,
}
I want to check optional parameter is set.
This worked for me.
const apiRequest = JSON.parse(req.body) as ChatCallApiRequest;
if (apiRequest.messages != undefined) {
// do something
}
Any other solutions?
Top comments (0)