0

i want to send custom headers with async request i am using React And design pro framework .

export async function AccountLogin(params) {
  console.log('params', params);
  return request('http://dreamfactory.com/api/v2/user/session', {
    method: 'POST',
    headers: {
      'X-DreamFactory-Api-Key': '36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88',
    },
    body: params,
  });
}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Uday Kumar
  • 121
  • 1
  • 10

1 Answers1

0

This could be done by jQuery.You can set a parameter headers to jQuery ajax, just like the code below

export async function AccountLogin(params) {
     $.ajax({
      method: "POST",
      url: "http://dreamfactory.com/api/v2/user/session",
      data:params,
      headers:{
     'X-DreamFactory-Api-Key': '36fda24fe5588fa4285ac6c6c2fdfbdb6b6bc9834699774c9bf777f706d05a88',
      }
    })
      .done(function( msg ) {
        alert( "Data Saved: " + msg );
      });
  }

jquery ajax

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Thomas.lin
  • 430
  • 1
  • 5
  • 11