Part 2 of annoying app dev gotchas – Making api requests

Cors is your best friend and worse enemy.

  1. Enable cors in your backend:
    config.EnableCors(); in Startup.MobileApp.Cs
  2. Add EnableCors attribute to your controller:
    [EnableCors(“*”, “*”, “*”)]
  3. Sample javascript for making request:

    Azureservice.invokeApi("chat/GetAccessToken", {
    method: 'get',
    body: null,
    parameters: {
    deviceId: window.device.uuid || 'browser',
    }
    })
    .then(function () {
    console.log('promise.success', arguments);
    }, function () {
    console.log('promise.fail', arguments);
    });