Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $http({
- method: 'POST',
- url: appConstant.webApiUrl + '/Token',
- data: userData,
- headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
- transformRequest: function (obj) {
- var str = [];
- for (var p in obj)
- str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
- return str.join("&");
- }
- }).success(function (data, status, headers, cfg) {
- var obj = {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
- //'Origin': '',
- //'Host': 'api.producthunt.com'
- },
- body: JSON.stringify({
- 'userName': 'test@gmail.com',
- 'password': 'Password!',
- 'grant_type': 'password'
- })
- }
- fetch('http://identity.azurewebsites.net' + '/token', obj)
- .then(function(res) {
- console.log(res)
- return res.json();
- })
- .then(function(resJson) {
- console.log(resJson)
- return resJson;
- })
- }
- },
- var str = [];
- var test = function(value){
- for (var p in value)
- str.push(encodeURIComponent(p) + "=" + encodeURIComponent(value[p]));
- return str.join("&");
- }
- test(value);
- var obj = {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
- },
- body:{data:str}
- }
- fetch('http://identity.azurewebsites.net' + '/token', obj)
- .then(function(res) {
- console.log(res)
- return res.json();
- })
- .then(function(resJson) {
- console.log(resJson)
- return resJson;
- })
- var params = {
- userName: 'test@gmail.com',
- password: 'Password!',
- grant_type: 'password'
- };
- var formData = new FormData();
- for (var k in params) {
- formData.append(k, params[k]);
- }
- var request = {
- method: 'POST',
- headers: headers,
- body: formData
- };
- fetch(url, request);
- var details = {
- 'userName': 'test@gmail.com',
- 'password': 'Password!',
- 'grant_type': 'password'
- };
- var formBody = [];
- for (var property in details) {
- var encodedKey = encodeURIComponent(property);
- var encodedValue = encodeURIComponent(details[property]);
- formBody.push(encodedKey + "=" + encodedValue);
- }
- formBody = formBody.join("&");
- fetch('http://identity.azurewebsites.net' + '/token', {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/x-www-form-urlencoded'
- },
- body: formBody
- })
- var data = new URLSearchParams();
- data.append('userName', 'test@gmail.com');
- data.append('password', 'Password');
- data.append('grant_type', 'password');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement