@mustafabekec wrote:
I am using Ionic Super Starter and I am trying http post to server. When i click the signup button I am getting an error.
What can I do to fix this problem?Http failure response for http://domain.com/v1/signup.php: 501 Not Implemented
// Default ionic account information | src\pages\signup account: { name: string, email: string, password: string } = { name: 'Test Human', email: 'test@example.com', password: 'test' };
// src\pages\signup doSignup() { // Attempt to login in through our User service this.user.signup(this.account).subscribe((resp) => { this.navCtrl.push(MainPage); }, (err) => { this.navCtrl.push(MainPage); // unable to sign up let toast = this.toastCtrl.create({ message: this.signupErrorString, duration: 3000, position: 'top' }); toast.present(); }); }
// src\pages\signup signup(accountInfo: any) { let seq = this.api.post('signup.php', accountInfo).share(); seq.subscribe((res: any) => { // If the API returned a successful response, mark the user as logged in if (res.success) { this._loggedIn(res); } }, err => { console.error('ERROR', err); }); return seq; }
// src\providers\api post(endpoint: string, body: any, reqOpts?: any) { return this.http.post(this.url + '/' + endpoint, JSON.stringify(body), reqOpts); }
//My Api <?php $response = array(); if (isset($_POST['name']) && isset($_POST['email']) && isset($_POST['password'])) { $name = $_POST['name']; $email = $_POST['email']; $password = $_POST['password']; $response["success"] = true; $response["message"] = "Success"; echo json_encode($response); } else{ $response["success"] = false; $response["message"] = "Failed"; echo json_encode($response); } ?>
Posts: 2
Participants: 2