import { Injectable } from '@angular/core';
import { RequestOptions, Headers, Response } from '@angular/http';
import { map } from 'rxjs/operators';
import { HttpClient, HttpHeaders } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class AuthService {
baseUrl = "http://localhost:3000/api/auth";
userToken: any;
httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
constructor(private http: HttpClient) {}
login(loginData: any) {
return this.http.post(this.baseUrl, loginData, this.httpOptions)
.pipe(
map((response: Response) => {
const user = response.json();
if (user) {
localStorage.setItem('token', user.token);
this.userToken = user.token;
}
})
)
}
}
这不会写入表,但不会引发任何错误。我在用户界面中立即查询数据库,以查看写入是否成功,并且显示0行。如果写入未成功完成,应该不会出现错误?
注意:工程师从阅读git问题开始说:
from google.cloud import bigquery
client = bigquery.Client()
dataset_ref = client.dataset('bigquery_error')
dataset = bigquery.Dataset(dataset_ref)
dataset.location = 'US'
dataset = client.create_dataset(dataset)
schema = [
bigquery.SchemaField('full_name', 'STRING'),
bigquery.SchemaField('age', 'INTEGER'),
bigquery.SchemaField('other', 'INTEGER'),
]
dataset_ref = client.dataset('bigquery_error')
dataset = bigquery.Dataset(dataset_ref)
table_ref = dataset_ref.table('user_table')
table = bigquery.Table(table_ref, schema=schema)
table = client.create_table(table) # API request
rows = [
('111', 9, 9),
(123, 123, 123),
]
# upload postgres data
table_ref = client.dataset('bigquery_error').table('user_table')
table = client.get_table(table_ref)
errors = client.insert_rows(table, rows)
print(errors)
assert errors == []