i have an error when i try to connect my api, i take http failer response for xyz.com
my ts file:
import { HttpClient } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators';
const headers = {
'Content-Type': 'application/json',
'secretkey': 'xxx',
'Access-Control-Allow-Origin' : '*',
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, PUT',
'Accept' : 'application/json',
}
const options = { headers:headers, withCredintials: true};
try {
this.httpClient.post('/xyz.com',{},options)
.pipe(catchError(this.handleError))
.subscribe(data => {
alert(JSON.stringify(data))
this.users = data;
},error=>{
alert("post catch error - "+error);
});
} catch (error) {
alert(JSON.stringify(error))
}
the output is:
and then this output is shown:
my android manifest is:
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="true" android:usesCleartextTraffic="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
i use php slim framework for backend.
i add headers for cors problem.
but i can’t save my app.
please help me. it’s emergency