Baidut Http Module
Methods
-
<static> requestHTTP(query, options)
-
Make a http/https request for spcified query with optional options. This is suitable for NodeJS application only.
Parameters:
Name Type Description query
String Text to translate. It can be in any language. If you specified non-chinese text, then you should also specific
from_lang
of options parameter to match that language code too, otherwise it will treat it as Chinese.options
Object (optional) options as object.
It can include
{http_request
: Boolean = set to true to make a request for Baidu's HTTP end-point. Otherwise, there's no effect to the call.http_get_method
: Boolean = set to true to make a HTTP GET method. Default is always send in HTTP POST method. Otherwise, there's no effect to the call.from_lang
: String = language code to translate from. Default value is 'zh'.to_lang
: String = language code to translate to. Default value is 'en'.
}Returns:
Promise object
- Type
- Object
-
<static> requestJSONP(query, options)
-
Make a jsonp request to target url. Warning: This is for browser only.
Parameters:
Name Type Description query
String Text to translate. It can be in any language. If you specified non-chinese text, then you should also specific
from_lang
of options parameter to match that language code too, otherwise it will treat as chinese.options
Object (optional) options as object
It can include
{http_request
: Boolean = set to true to make a request for Baidu's HTTP end-point. Otherwise, there's no effect to the call.from_lang
: String = language code to translate from. Default value is 'zh'.to_lang
: String = language code to translate to. Default value is 'en'.
}Returns:
Promise object
- Type
- Object