我正在使用angular 4和http服务,我想调用一个服务并传递一个字符串以返回JSON值。我的字符串是“ 97/422/1883”,我的服务代码是:
getIncomingRelatedById(number) {
this.createAuthenticationHeaders();
return this.http.get(this.domain + '/mail/getIncomingRelatedById/' + number, this.options).map(res => res.json());
} 但是当我运行代码时,出现以下错误:
http://localhost:3000/mail/getIncomingRelatedById/97/422/1883 404 (Not Found)
我现在如何发送我的请求?
更新:
在服务器端我有这个:
router.get('/getRelatedById/:id', (req, res) => {
pool.connect((err, client, done) => {
if (err) {
res.json({
success: false,
message: err
});
} else {
client.query('select * from get_related_mail($1)', [req.params.id],
(err, mail) => {
done();
if (err) {
console.log(err);
res.json({
success: false,
message: err
});
} else {
res.json({
success: true,
mail: mail,
});
});
}
});
});
答案 0 :(得分:1)
我认为此链接有帮助 https://www.w3schools.com/tags/ref_urlencode.asp
这样具有所有字符和值
对于您的问题,这是您的角色
var map = L.map('map', {
minZoom: 9,
maxZoom: 15,
}).setView([48.86, 2.35], 11);
var fg = L.featureGroup().addTo(map);
L.marker([49, 2.35]).addTo(fg);
L.marker([48.5, 2.35]).addTo(fg);
map.fitBounds(fg.getBounds());
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);