我在 aws lambda 中调用 axios post 方法。大多数时候 lambda 不返回任何结果。日志显示以下结果
START RequestId:ac92d268-d212-4b80-a06c-927922fcf1d5 版本:$LATEST END RequestId:ac92d268-d212-4b80-a06c-927922fcf1d5
但有时 lambda 会返回预期的结果。看起来 lambda 没有等待 axios 完成。下面是 lambda 代码。
var axios = require('axios')
exports.handler = async (event, context,callback) => {
axios.post('https://example.com/testapi/api.asmx/GetNames', {})
.then((res) => {
console.log(JSON.stringify(res.data,null,2))
callback(null,'success');
})
.catch((error) => {
console.error(error)
callback(null,'error');
})
};
Run Code Online (Sandbox Code Playgroud) 我使用 umbraco 创建了一个工作流程,我想做的是:创建一个工作流程,获取由 razor 模板 ( umbraco.forms) 创建的 html。
这是模板的位置umbraco.forms
Views\Partials\Forms\Emails 此模板是我想要在调用此工作流程时通过电子邮件发送的模板。
public class SendMail : WorkflowType
{
//Here I get the path where the razor template is
[Umbraco.Forms.Core.Attributes.Setting("Path to template",
Description = "Path to template",
View = "TextField")]
public string Template{ get; set; }
public SendMail()
{
this.Id = new Guid("ccbeb0d5-adaa-4729-8b4c-4bb439dc0204");
this.Name = "Send Mail";
this.Description = "Send Mail";
this.Icon = "icon-plugin";
this.Group = "Services";
}
//When workflow get called this method is executed
public override WorkflowExecutionStatus …Run Code Online (Sandbox Code Playgroud) 是否可以在不将助焊剂转化为流的情况下从助焊剂中获得第一个元素?
我正在开发一个ASP.Net核心,MVC 6应用程序.我有一个AppControler作为我的初始控制器,如果用户试图转到具有[Authorize]属性的动作,我会重定向到我的AuthController进行登录,传入returnUrl返回.经过身份验证后,我使用...返回RedirectToAction(returnUrl).
在debug中,我可以看到returnUrl字符串设置为/ App/Timesheets.但是,在浏览器地址栏中,它的地址为http:// localhost:49940/Auth /%2FApp%2FTimeSheets.由于某种原因,它将控制器名称(Auth)附加在returnUrl之前.
这是我在AuthController中的Login操作
[HttpPost]
public async Task<ActionResult> Login(LoginViewModel vm, string returnUrl)
{
if (ModelState.IsValid)
{
var signInResult = await _signInManager.PasswordSignInAsync(vm.Username, vm.Password, true, false);
if (signInResult.Succeeded)
{
if (string.IsNullOrWhiteSpace(returnUrl))
{
return RedirectToAction("Timesheets", "App");
}
else
{
return RedirectToAction(returnUrl);
}
}
else
{
ModelState.AddModelError("", "Username or password incorrect");
}
}
return View();
}
Run Code Online (Sandbox Code Playgroud)
我可以在浏览器地址栏中手动输入http:// localhost:49940/App/Timesheets并进入正确的视图.另外,如果我添加
returnUrl = String.Empty; //Test Only
Run Code Online (Sandbox Code Playgroud)
在线之前......
if (string.IsNullOrWhiteSpace(returnUrl))
Run Code Online (Sandbox Code Playgroud)
使它执行线...
return RedirectToAction("Timesheets", "App");
Run Code Online (Sandbox Code Playgroud)
重定向工作得很好.所以它与"/Controller/Action"以问题格式传递字符串变量有关.
有任何想法吗?
我想仅在列表中尚未添加classStudents到列表中._ClassStudentsclassStudents
public class ClassStudents{
public Id {get; set;}
public Name {get; set;}
public List<Student> Student {get; set;}
}
public static List<ClassStudents> _ClassStudentsList = new List<ClassStudents>();
public static void addClassStudents(ClassStudents classStudents)
{
//if( classStudents isn't in ClassStudentsList ) <------
_ClassStudentsList.Add(classStudents);
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我有一个Player对象数组。播放器具有名称,当我添加播放器时,我想检查播放器名称是否已经存在。以下代码永远不会引发异常,它只会添加重复的播放器。
public void addPlayer(String name, boolean gender, int index) throws RuntimeException {
List<String> names = new ArrayList<>();
if (names.contains(name))
throw new DuplicatePlayerException();
else {
players[index] = new Player(name, gender);
names.add(name);
}
}
Run Code Online (Sandbox Code Playgroud)