Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70440

Issue in Native HTTP with POST request in iOS

$
0
0

@OmDIonic wrote:

I am trying POST request using native HTTP in iOS but its not working.
GET with both angular http and native http working perfect but POST with angular and native http not working.

My Ionic Info:
Ionic:

ionic (Ionic CLI) : 4.10.3 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.1.1
@angular-devkit/build-angular : 0.13.5
@angular-devkit/schematics : 7.2.4
@angular/cli : 7.3.5
@ionic/angular-toolkit : 1.4.0

Cordova:

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 8 other plugins)

System:

ios-deploy : 1.9.4
ios-sim : 8.0.0
NodeJS : v10.15.3 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS High Sierra
Xcode : Xcode 10.1 Build version 10B61


Code for POST request in iOS

import { HTTP } from ‘@ionic-native/http/ngx’;

const httpOptions = {
headers: new HttpHeaders({
‘Authorization’: Authorization,
‘Content-type’ : ‘application/json’,
})
};

const body = new HttpParams()
.set(‘grant_type’, ‘authorization_code’)
.set(‘client_id’ , this.client_id)
.set(‘redirect_uri’, this.redirect_url)
.set(‘code’,code);

this.http.post(this.token_url, body,httpOptions)
.then(data => {
console.log(’–token res–’+JSON.stringify(data));
})
.catch(error => {
console.log(’–token err–’+JSON.stringify(error));
});

can anybody help me out here.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70440

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>