LoopBack is an open source Node.js framework built on top of Express optimized for mobile, web, and other devices. Connect to multiple data sources, write business logic in Node.js, glue on top of your existing services and data, connect using JS, iOS & Android SDKs.
bajtos on add-node10
Hi everyone,
I am working on creating dynamic models and repositories in lb4. I came across this issue:
'BookModel' refers to a value, but is being used as a type here. Did you mean 'typeof BookModel'. in
'''
const DynamicRepositoryClass = defineCrudRepositoryClass<
BookModel, // issue is here
typeof BookModel.prototype.id,
{}
>(BookModel);
'''
But if typeof is used I get an error as follows:
Type 'DynamicModelCtor<typeof Entity, { id: number; title?: string | undefined; }>' does not satisfy the constraint 'Entity'.
I used the Model definitions as given in the documentation https://loopback.io/doc/en/lb4/Dynamic-models-repositories-controllers.html#defining-a-datasource
'''
const bookDef = new ModelDefinition({
name: 'book',
properties: {
....
},
},
title: {
},
settings: {
idInjection: false,
mysql: {schema: 'test', table: 'BookStore'},
},
});
const BookModel = defineModelClass<typeof Entity, {id: number; title?: string}>(
Entity,
bookDef,
);
'''
Please help.
POST /api/Customers
with some irrelevant json data...
Hi people, ho are you ?
how can I select the fields to show on well Model ??
Regards
Hi
I am using loopback 4 for backend and react for front end.
when I make a request on API, it gives me blocked Cors.
I tried this :
let config = {
mode: 'cors',
cache: 'no-cache',
credentials: 'same-origin',
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
},
redirect: 'follow',
referrerPolicy: 'no-referrer',
}
const response = await axios.post(${API}/signUppatient
, obj, config);
but it didn't work
const config = {
name: 'ipfs',
connector: 'rest',
baseURL: 'http://localhost:5001/api/v0/',
crud: false,
operations: [
{
template: {
method: 'POST',
url: 'http://localhost:5001/api/v0/add',
headers: {
'content-type': 'multipart/form-data;'
},
query: {
'only-hash': true,
},
form: {
file: '{file}',
},
},
functions: {
getCID: ['file'],
},
},
{
template: {
method: 'POST',
url: 'http://localhost:5001/api/v0/bootstrap/list',
},
functions: {
getPeers: [],
},
},
],
};
export interface Ipfs {
getCID(file: Buffer): Promise<CID>,
getPeers(): Promise<unknown>
}
allowArray
in an option somewhere. However, I have not found where this option should be inserted. In the model json description I assume, but where?