-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Here's my basic test script bundled with browserify & loaded on client side browser
var ws_api_client = require('ws-api-client-nodejs');
var defaultClient = ws_api_client.ApiClient.instance;
// Configure API key authorization: user_key
var user_key = defaultClient.authentications['user_key'];
user_key.apiKey = "*****"
var api = new ws_api_client.MakesApi()
var opts = {
'countries': "us" // {String} Show information for local manufacturers from specified countries only. Use `GET /countries/` method to get the full list of countries. (e.g. `us,gb,jp`)
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data, null, 2));
}
};
api.makesList(opts, callback);
and console output with 403 error:

Looks like superagent is setting content type header to application/json which causes browser to do a preflight OPTION request, turning this into a CORS issue.
Changing this line to request.type("text/plain"); seems to fix the problem (it becomes a 'simple' request)
Or is this a sign that I shouldn't be using this on client side?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels