Make config parameter optional in Google Translate service
Updated the translateWithGoogle function to accept an optional config parameter and handle missing clientIP values gracefully. This improves flexibility and prevents errors when config or its properties are undefined.
This commit is contained in:
1 parent
c54500dc79
commit
0b8d562117
1 file changed
+2
-2
@@ -19,7 +19,7 @@ import {
|
||||
*/
|
||||
export async function translateWithGoogle(
|
||||
params: RequestParams,
|
||||
config: Config & { env: any; clientIP: string }
|
||||
config?: Config & { env?: any; clientIP?: string }
|
||||
): Promise<ResponseParams> {
|
||||
try {
|
||||
const { text, source_lang, target_lang } = params;
|
||||
@@ -88,7 +88,7 @@ export async function translateWithGoogle(
|
||||
|
||||
const errorResponse = createErrorResponse(error, {
|
||||
endpoint: "/google",
|
||||
clientIP: config.clientIP,
|
||||
clientIP: config?.clientIP || "unknown",
|
||||
});
|
||||
|
||||
return errorResponse.response;
|
||||
|
||||
Reference in new issue
Block a user