我已经使用 string.charCodeAt() 将字符串转换为它们的 ascii,但是现在我已经完成了添加/减去值,我想将它们从 ASCII 转换回字母和字符串。
我希望将以下数组转换回它们的字符字母,并最终使用 JavaScript 转换为字符串。
asciiKeys= [70, 69, 69, 69, 32, 67, 66, 68, 69, 32, 67, 65, 77, 67];
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下内容,但它一直声明它不是一个函数:
for (var j=0;j<str.length;j++){
newAsciikeys.push(asciiKeys[j].fromCharCode(0));
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试向上传到 Heroku 的 Rails API 发出 POST 请求。目前我正在使用邮递员进行测试,只是为了确保它在那里工作,然后再继续在 heroku 应用程序之间进行测试。在本地,我能够与 React 前端和 Rails API 后端进行交互。本地主机没有问题。
URL: https://appname.herokuapp.com/api/v1/users/
headers:
key: Access-Control-Allow-Origin, value: *
//I have also removed the access control allow origin so with and without.
key: Content-type, value: application/json
Run Code Online (Sandbox Code Playgroud)
创建用户时传入的数据确实已创建,但返回响应是 500 内部服务器错误
[
{
"id": 1,
"first_name": "Roger",
"last_name": "Perez",
"email": "roger@yahoo.com",
"birthday": "2000-10-10",
"gender": "male",
"avatar": null,
"home_base": null,
"initials": null,
"comments": [],
"events": [],
"user_events": [],
"messages": []
},
Run Code Online (Sandbox Code Playgroud)
导轨
class Api::V1::UsersController < ApplicationController
# before_action :requires_login, only: …Run Code Online (Sandbox Code Playgroud)