Why is app.store.find not sending requests?
money\extend.php
(new Extend\Routes('api'))
->get('/money-point-types', 'money-point-types.index', ListPointTypesController::class)
get xxxx.com/api/money-point-types
{
"data": [
{
"type": "money-point-types",
"id": "1",
"attributes": {
"id": 1,
"name": "aaa",
"createdAt": null
}
},
{
"type": "money-point-types",
"id": "10",
"attributes": {
"id": 10,
"name": "bbb",
"createdAt": null
}
}
]
}
money\js\src\admin\models\PointType.js
import Model from 'flarum/common/Model';
import mixin from 'flarum/common/utils/mixin';
export default class PointType extends mixin(Model, {
id: Model.attribute('id'),
name: Model.attribute('name'),
createdAt: Model.attribute('createdAt')
}) {}
Now I'm asking why I can't send a request or get api data in this file below?
money\js\src\admin\index.js
import app from 'flarum/admin/app';
import PointType from './models/PointType';
app.initializers.add('shebaoting-money', () => {
app.store.models['money-point-types'] = PointType;
app.store.find('money-point-types').then((types) => {
console.log('Point types loaded successfully:', types); //No printing is performed here
}).catch(error => {
console.error('Failed to load money-point-types:', error); // The error is shown here
});
app.extensionData
.for('shebaoting-money')
.registerSetting(function () {
const pointTypes = app.store.all('money-point-types');
return (
<div className="Form-group">
<label>{app.translator.trans('shebaoting-money.admin.settings.moneyforpost_label')}</label>
<div className="MoneySettingRow">
<input
className="FormControl"
type="number"
min="0"
bidi={this.setting('shebaoting-money.moneyforpost')}
placeholder="0"
/>
<select
className="FormControl"
bidi={this.setting('shebaoting-money.pointtype_post')}
>
//The following options are not available here
{pointTypes.map(type => (
<option value={type.id()} key={type.id()}>
{type.name()}
</option>
))}
</select>
</div>
<div className="helpText">
{app.translator.trans('shebaoting-money.admin.settings.moneyforpost_help')}
</div>
</div>
);
});
});
Why isn't app.store.find sending any requests, I'm in the developer tools in my browser and I don't see any requests sent