fetch跨域调用datasnap接收JSON对象方法

    fetchData() {
       (async ()=> {
  
        const valueObj = {
          UserName: ‘jjw‘,
          Tel: ‘123456‘
        }

        let d2 = await fetch(‘http://127.0.0.1:8080/datasnap/rest/TServerMethods1/"TestPost"‘, {
          method: ‘POST‘,
          headers: {
            ‘Authorization‘: ‘Basic ‘ + btoa(‘jjw‘+‘:‘+‘jjw‘),
          },
          body: JSON.stringify(valueObj),
        });
        console.log(await d2.json());
       })();
    }
function TServerMethods1.TestPost(Value: TJSONObject): string;
var
  User: TUser;
begin
  Result := Value.ToString;
  try
    User := TBaseObject.JSONToObject<TUser>(Value);
    if User.UserName=jjw then
      Result := ok
    else
      Result := xxx;
    User.Free;
  except
    Result := asdfasdfasd;
  end;
end;
procedure TWebModule1.DSAuthenticationManager1UserAuthenticate(Sender: TObject;
  const Protocol, Context, User, Password: string; var valid: Boolean;
  UserRoles: TStrings);
begin
  if (User=jjw) and (Password=jjw) then
    UserRoles.Add(admin)
  else
    valid := False;
end;

 

fetch跨域调用datasnap接收JSON对象方法

上一篇:php代码审计----20201104


下一篇:JSP启动,错误500,实例化Servlet类异常