我正在使用Ionic 2 Beta 11.我正在尝试向外部API发送请求,该API将返回JSON响应.我已经克服了CORS问题,我正在与API通信但是我无法发送所需的正文信息.我尝试用以下方式格式化body变量,每个都没有成功:
作为对象: {email: this.email, password: this.password}
作为字符串化对象: JSON.stringify({email: this.email, password: this.password})
作为一个字符串: 'email=' + this.email + '&password=' + this.password
这是我的代码:
import {Component} from '@angular/core';
import {NavController, MenuController} from 'ionic-angular';
import {Http, Headers, RequestOptions} from '@angular/http';
import 'rxjs/Rx';
@Component({
templateUrl: 'build/pages/login/login.html'
})
export class LoginPage {
nav: NavController;
username: string;
password: string;
constructor(nav: NavController, private http: Http) {
this.nav = nav;
}
doLogin() {
let body = JSON.stringify({
email: this.username,
password: this.password });
let headers = …Run Code Online (Sandbox Code Playgroud) 这是我过去的考试试卷中的一个问题.请帮忙.
给出超市票据的类型.该法案的每个条目都包含产品名称,购买该产品的数量以及单个产品的价格.
type Product = String
type Count = Float -- type chosen for simple arithmetic
type Price = Float
type Bill = [(Count, Product, Price)]
Run Code Online (Sandbox Code Playgroud)
定义一个函数mostExpensive,鉴于一项法案,将返回的产品名称和该法案的最昂贵的项目的总成本(考虑如何将产品的许多项目被买).假设只有一个这样的产品.